How can I check for IsPostBack in JavaScript?


This question already has an answer here:


Server-side, write:

   // NOTE: the following uses an overload of RegisterClientScriptBlock() 
   // that will surround our string with the needed script tags 
   ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack", "var isPostBack = true;", true);

Then, in your script which runs for the onLoad, check for the existence of that variable:

if(isPostBack) {
   // do your thing

You don't really need to set the variable otherwise, like Jonathan's solution. The client-side if statement will work fine because the "isPostBack" variable will be undefined, which evaluates as false in that if statement.

Need Your Help

Safari extension: Event for a completely new tab?

javascript javascript-events safari safari-extension

I'm looking to redirect new tabs in Safari to a certain URL, in essence changing the default new tab page. However, I do not want to redirect new tabs that are opened by following links.

Reason for different speeds of floating point division with and without opt.flag -O3 (C++/C)

c++ c gcc floating-point

I was trying to measure the speed difference of single precision division vs double precision division in C++

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.