Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect/track postback in javascript?

How to detect/track/check postback in javascript(e.g in asp.net Page.isPostBack())? Any suggestion?

like image 418
Subrat Avatar asked Dec 07 '09 03:12

Subrat


People also ask

What is PostBack in Javascript?

Postback is a mechanism where the page contents are posted to the server due to an occurrence of an event in a page control. For example, a server button click or a Selected Index changed event when AutoPostBack value is set to true.

What happens during PostBack?

PostBack is the name given to the process of submitting an ASP.NET page to the server for processing. PostBack is done if certain credentials of the page are to be checked against some sources (such as verification of username and password using database).


1 Answers

ASPX:

<input type="hidden" id="_ispostback" value="<%=Page.IsPostBack.ToString()%>" /> 

Client-side Script:

function isPostBack() { //function to check if page is a postback-ed one   return document.getElementById('_ispostback').value == 'True'; } 

PS: I have not tested it but I've done somthing similar before and it works.

like image 143
o.k.w Avatar answered Sep 24 '22 15:09

o.k.w