Monday, June 3, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
32
rated 0 times [  34] [ 2]  / answers: 1 / hits: 18094  / 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#

 Answers
29

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
}

[#90517] Thursday, August 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bradleymoisesy

Total Points: 121
Total Questions: 105
Total Answers: 95

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;