Tuesday, December 30, 2008

Client Side Post Back

The simple code that will postback the page from client side is shown below.

__doPostBack('control_clientID','OnClick');

The first parameter is control's ID and the second one is argument passed which can be accessed on the server side. The controlID and argument is populated in the page's hidden variable __EVENTTARGET and __EVENTARGUMENT respectively. The values can also be accessed from Forms/Param collection as below,
string controlID = Request.Params.Get("__EVENTTARGET");
will get us the control that caused the postback.

Button and ImageButton are not supported under this because they don't call __doPostBack method call in their html page(if View Souce is seen) and so the __EVENTTARGET variable is empty.

0 comments: