Determine if and which partial postback occurred in pageLoad() with JavaScript in .NET -
as understand it, partial page updates asp.net ajax cause javascript pageload() event handler invoked.
my question: there generic way of determining in javascript within pageload() function...
i) if postback partial page update or not.
ii) if so, panel updated.
my application uses combination of .net updatepanels & telerik radajaxpanels. i'm looking generic (preferably javascript) solution doesn't require me specify unique client-side callback function each panel, nor set flag within each postback event handler identify client-side.
to determine if postback partial update or not, can use scriptmanager.getcurrent(this.page).isinasyncpostback
. here's example:
protected void page_load(object sender, eventargs e) { if (page.ispostback) { // reference scriptmanager , check if have 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 update panel caused postback, can scriptmanager.getcurrent(page).uniqueid
, analyze it. here's 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:
Comments
Post a Comment