Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can we identify that the Page is Post Back?

user-image
Question added by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
Date Posted: 2013/01/22
marwa khalaf
by marwa khalaf , .Net Developer , Sands National Academy

Page object has an "IsPostBack" property, which can be checked to know that is the page posted back.

Furqan Ul Karim
by Furqan Ul Karim , Senior Delivery Manager (Contract) , Virgin Red

Page's IsPostBack property in asp.net.
you can also figure out by checking the value for the hidden control __EVENTTARGET and __EVENTARGUMENT where __EVENTTARGET contains the control id caused the postback and later one will hold the value

if (basename($_SERVER['HTTP_REFERER']) == $_SERVER['YOUR_SCRIPT_NAME']) { // DO SOMETHING }

Hazem Salama
by Hazem Salama , Senior Member of Technical Staff , Verizon Communications

Page.IsPostBack method

Rahul. K Nair Chaithrakam
by Rahul. K Nair Chaithrakam , Senior Software Engineer , Emirates airlines

With the help of “IsPostBack” property In Asp.net we can check if a page is rendered for the first time or responding to a post back.

Eg:

            protectedvoid Page_Load(object sender, EventArgs e)

                {

                if (!IsPostBack)

                {

                    // Can write code here or call the method you want

                }

 

                if (IsPostBack)

                {

                     //Can write code here or call the method you want

                }

 

                }  

Page object has an "IsPostBack" property, which can be checked to know that is the page posted back to server or not, if "IsPostBack" property is "True" then page called postback and page loading through the "Post" Request (page loading second or higher time) else if "IsPostBack" property returns false then page is loading through "Get" Request (page loading first time).

Rani Alomari
by Rani Alomari , Full Stack .Net Developer , Jordan Center for Diseases Control (JCDC)

by checking the control's property 'IsPostBack'

Mohammad Ibrahim Rashid
by Mohammad Ibrahim Rashid , IT Consultant (Information Technology Consultant) , SABIC Petrochemicals

In Page_Load Event of your page you can test "IsPostBack" Property of your page instance.

Maher Alsilwy
by Maher Alsilwy , CONSULTANT , B7R DESIGN WWW.B7RDES.COM

in the Page_Load Event check this condition if(isPostBack == false) { // here your code }

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.