32
rated 0 times
[
34]
[
2]
/ answers: 1 / hits: 18095
/ 13 Years ago, fri, august 19, 2011, 12:00:00
Is there a way to detect if when the page loads it is a postback or just the page loading?
More From » c#
Is there a way to detect if when the page loads it is a postback or just the page loading?
JavaScript has no concept of post back. The simplest way to detect this client-side would be to have [Insert Your Server Side Language Here] write/set a JavasScript variable on post back.
In C#, it would look a bit like this:
ClientScript.RegisterClientScriptBlock(GetType(),
isPostBack,
String.Format(var isPostback = {0};, IsPostBack.ToString().ToLower()),
true);
JavaScript:
if(isPostback) {
// Postback specific logic here
}