A day before I was playing with some functionality where I had to get the id of the element which caused the postback. If its a normal postback done with some control. We can retrieve the postback element with the code below.
string controlID = Page.Request.Params["__EVENTTARGET"];
If we use a UpdatePanel on the page, and if its a asynchronous postback with some control inside the Content template of Update panel, you will observe that EVENTTARGET parameter will be blank. So How to get the postback element id in asynchronous postback caused by Updatepanel in ASP.NET ?
Please use the function below to get the Async postback element id.
/// This function retrieves the ID of the control that caused the asynchronous postback.
public string GetAsyncPostBackControlID()
string smUniqueId = ScriptManager.GetCurrent(Page).UniqueID;
string smFieldValue = Request.Form[smUniqueId];
if (!String.IsNullOrEmpty(smFieldValue) && smFieldValue.Contains('|'))
Hope it helps.
Love ASP.NET tips ? For more Subscribe here or click here to get updates via email