Page load vs. reload ?

  • Thread starter Thread starter Zeba
  • Start date Start date
Z

Zeba

Hi !

How do I distinguish a page reload event ( i mean a page_load due to
some clicks, etc. which dont cause a postback) from a page load event
( the first time the page loads) ??

Thanks !
 
your answer is hidden in your question
There is a property that you can check to find that
and it is "IsPostback"

example code

protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
//This is a reload, also known as a post back and is caused by an
event on the same page
}
else
{
//This is first load as a result of first browser request or simply
clicking a link on a different page that brings you here or a redirect
}
}
 
Hi Kareem,
Thank you, but I was actually looking for something to detect the page
reload when it isn't a post back .. such as when Ajax calls are used.
I finally set a hidden variable in the aspx page (default value null)
and set it to some value in the code behind. So the first time, the
hidden variable is null, but on all subsequent reloads ( which dont
involve refresh) it will be null.

Thanks !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top