ViewState with example in C#

Saturday, January 8, 2011

_doPostBack() in javascript in

Calling postback event from Javascript

There may be some scenario where you may want to explicitly postback to the server using some clientside javascript. It is pretty simple to do this.

ASP.NET already creates a client side javascript method as shown below to support Postbacks for the web controls:

function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;

So, all you have to do is, just call this method with appropriate arguments. You may call this as shown below:

<script language='Javascript'>
__doPostBack('__Page', 'MyCustomArgument');

No comments:

Post a Comment