Updating a session variable without postback

updating a session variable without postback-20
Are you interested in knowing how the __do Post Back function looks like? Just create a sample page and drop a textbox server control with Auto Post Back = true. The EVENTTARGET is the ID of the control that caused the postback and the EVENTARGUMENT contains any arguments passed that can be accessed on the server.

Such controls, when placed inside an Update Panel, cause a partial page postback to occur.

On a partial page postback only the contents of the Update Panel are refreshed, avoiding the "flash" of having the entire page reloaded.

When the user clicks the button, the Java Script method is now called which in turn explicitly calls the __do Post Back thereby passing the Java Script variable (js Var) as an EVENTARGUMENT.

We then access this hidden variable EVENTARGUMENT using our server side code and set the value of the textbox. There are a few more ways including AJAX calls using which you can pass Java Script variables during postback and access them using server-side code.

For example, a Button Web control placed within an Update Panel will cause a partial page postback when clicked.

It's also possible to have Web controls outside of the Update Panel trigger a partial page postback.

This is accomplished by specifying that the Web control of interest is an Async Postback Trigger for the Update Panel.

Refreshing an Update Panel from client-side script requires that we trigger a partial page postback.

(For a more in-depth look at the Update Panel control, refer back to the Using the Update Panel installment in this article series.) Triggering a partial page postback refreshes the contents within an Update Panel, but what if you want to refresh an Update Panel's contents via Java Script?

Ideally, the Update Panel would have a client-side function named something like that could be called from script to perform a partial page postback and refresh the Update Panel. Instead, you have to write script that triggers a partial page postback for the Update Panel you want to refresh.


Comments Updating a session variable without postback

The Latest from altay-blog.ru ©