As I understand it, partial page updates with ASP.NET AJAX cause the JavaScript pageLoad() event handler to be invoked.
My question: Is there a generic way of determining in JavaScript from within the pageLoad() function...
i) If the postback was a partial page update or not.
ii) If so, which panel was updated.
My application uses a bination of .NET UpdatePanels & Telerik RadAjaxPanels. I'm looking for a generic (preferably JavaScript) solution which doesn't require me to specify a unique client-side callback function for each panel, nor set some flag from within each postback event handler to identify itself to the client-side.
As I understand it, partial page updates with ASP.NET AJAX cause the JavaScript pageLoad() event handler to be invoked.
My question: Is there a generic way of determining in JavaScript from within the pageLoad() function...
i) If the postback was a partial page update or not.
ii) If so, which panel was updated.
My application uses a bination of .NET UpdatePanels & Telerik RadAjaxPanels. I'm looking for a generic (preferably JavaScript) solution which doesn't require me to specify a unique client-side callback function for each panel, nor set some flag from within each postback event handler to identify itself to the client-side.
Share Improve this question edited Mar 22, 2016 at 21:21 gariepy 3,6746 gold badges23 silver badges34 bronze badges asked Apr 9, 2013 at 3:55 BumpyBumpy 1,3322 gold badges22 silver badges33 bronze badges 01 Answer
Reset to default 21To determine if the postback was a partial update or not, you can use ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack
. Here's an example:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
// get a reference to ScriptManager and check if we have a partial postback
if (ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)
{
// partial (asynchronous) postback occured
// insert Ajax custom logic here
}
else
{
// regular full page postback occured
// custom logic accordingly
}
}
}
And to get the Update Panel that caused the PostBack, you can look into ScriptManager.GetCurrent(Page).UniqueID
and analyze it. Here's an example of doing that:
public string GetAsyncPostBackControlID()
{
string smUniqueId = ScriptManager.GetCurrent(Page).UniqueID;
string smFieldValue = Request.Form[smUniqueId];
if (!String.IsNullOrEmpty(smFieldValue) && smFieldValue.Contains("|"))
{
return smFieldValue.Split('|')[0];
}
return String.Empty;
}
References:
- http://forums.asp/t/1562871.aspx/1
- Get ASP.NET control which fired a postback within a AJAX UpdatePanel