Use javascript to determine if an ASP.NET page is postback

Is it possible to determine if an ASP.NET page is javascript postback? So basically the javascript equivalent of C # Page.IsPostBack.

Thanks.

+5
source share
3 answers

I would just put a rendering tag in javascript

var isPostBack = <%= Page.IsPostBack ? "true" : "false" %>;

Putting "true" and "false" as strings should be done to eliminate any possible problems associated with converting a type to a string, as in C # true. ToString () is usually "True", which is a javascript error.

+14
source

. , javascript, .

, .

+2

I'm not quite sure what you are trying to do, but you can look in PageRequestManagerClass:

http://www.asp.net/AJAX/Documentation/Live/ClientReference/Sys.WebForms/PageRequestManagerClass/default.aspx

It provides events for all the different parts of the request.

0
source

All Articles