If you look back on one of my previous posts on the UpdatePanel, you'll see that I cover a function called __doPostBack() located deep within the Atlas clientside framework. This is a very important method as it is not only the method that begins the partial postback sequence for Atlas controls, but also something that you can call yourself to programmatically cause a partial postback via javascript. __doPostBack() simply takes an eventTarget and eventArgument as parameters, detects if a partial postback is already occuring and, if not, sets appropriate form values (like _EVENTTARGET, _EVENTARGUMENT) that are used by the ASP.Net server runtime and then initiates a partial postback. The postback proceeds as if it were initiated by the eventArgument (which should be a reference to a HTML control on the page), like thus:
__doPostBack('<%= Button_Search.ClientID %>','');
Now, why would you want to do something like this? Under what circumstances would this be important? One instance that comes to mind immediately is having a child window refresh contents of a parent window, or to refresh contents of an UpdatePanel when a modal dialog closes, etc. All of these instances are not ones that are easily catchable from the Atlas framework alone, and so may require coding on your part. Many other situations probably exist out there.
For purposes of academia, here is the code for __doPostBack(); note that the rabbit hole of code contines at _onFormSubmit, but this is details you really ought to not care about in this situation:
this._doPostBack = function(eventTarget, eventArgument) { _additionalInput = null; if (this.get_inPostBack()) { if (window.event) { window.event.returnValue = false; } return; } _postbackSettings = null; var postbackElement = findNearestElement(eventTarget); if (postbackElement) { _postbackSettings = getPostbackSettings(postbackElement); } else { _postbackSettings = createPostbackSettings(true, _scriptManagerID); } if (!_postbackSettings.async) { _originalDoPostBack(eventTarget, eventArgument); return; } var form = _form; form.__EVENTTARGET.value = eventTarget; form.__EVENTARGUMENT.value = eventArgument; this._onFormSubmit(); if (window.event) { window.event.returnValue = false; }}
Remember Me
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.