Pages

Sep 21, 2009

How to check for postback in clientside javascript

Javascript Ispostback Method :

Normally we use IsPostback method in the server side to check for postback. But there may be some situations where we really need this on clientside.
So lets see how to do this

// Client side postback Identification


function IsPostBack() {


return < %= IsPostBack.ToString().ToLower() % >;


}
 
The above method will return the boolean value indicating whether it is a postback or not. we can use like below
 
if(!IsPostBack())
{
   // To do
}
else
{
  // To do
}
 
So Checking for postback in clientside javacript is possible.

2 comments:

Rathish M R said...

You are real lion

Anonymous said...

When and where this script will run? on client side??