Questions tagged [page-lifecycle]

When a page is requested on the web the server goes through a number of stages before sending back a response. Thus, the page life cycle is runs between request to response on the server.

Main steps in lifecycle are:

  1. Page request
  2. Start
  3. Initialization
  4. Load
  5. Postback event handling (if it is a postback request)
  6. Rendering
  7. Unload

More information: http://msdn.microsoft.com/en-us/library/ms178472.aspx

471 questions
64
votes
8 answers

On postback, how can I check which control cause postback in Page_Init event

On postback, how can I check which control cause postback in Page_Init event. protected void Page_Init(object sender, EventArgs e) { //need to check here which control cause postback? } Thanks
Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
52
votes
2 answers

C# Clear Session

Question #1 I want to know when am I supposed to use: Session.Abandon() // When I use this during tracing and after calling it- I find the session still has a value. And when am I supposed to use : Session.Clear() When should I use each…
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
44
votes
5 answers

What is the difference between Page.IsPostBack and Page.IsCallBack?

I've recently ran into some code that checks Page.IsCallBack but I wasn't sure how it is different from Page.IsPostBack. Can anyone enlighten me? Edit: Are they mutually exclusive or can both occur at the same time in a given situation?
Joe Phillips
  • 49,743
  • 32
  • 103
  • 159
43
votes
4 answers

ASP.NET: What happens to code after Response.Redirect(...)?

Does Response.Redirect() cause the currently running method to abort? Or does code after Response.Redirect() execute also? (That is, is it necessary to return/Exit Sub after a Response.Redirect?)
Brandon
  • 13,956
  • 16
  • 72
  • 114
42
votes
2 answers

Is there an after Page_Load event in ASP.net

Is there an event that is triggered after all Page_Load events have completed? How can i have more than one Page_Load? When you have user controls. Before my page can render, i need my page (and all embedded controls) to have initialized…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
37
votes
3 answers

ASP.NET page life cycle explanation

I was asked to explain the ASP.NET page life cycle in an interview some time back. I did explain it to him, but he was not satisfied with my answer. Could someone explain the life cycle to me please?
Sharique
  • 4,199
  • 6
  • 36
  • 54
36
votes
4 answers

Page lifecycle events in xamarin.forms

I just developed my first xamarin.forms app. I am excited about xamarin.forms, but I miss several events. Are there any page-lifecycle-events in a xamarin.forms ContentPage? I know of these two: protected override void OnAppearing() { } protected…
Joehl
  • 3,671
  • 3
  • 25
  • 53
34
votes
6 answers

How to Execute Page_Load() in Page's Base Class?

I have the following PerformanceFactsheet.aspx.cs page class public partial class PerformanceFactsheet : FactsheetBase { protected void Page_Load(object sender, EventArgs e) { // do stuff with the data extracted in FactsheetBase …
DaveDev
  • 41,155
  • 72
  • 223
  • 385
32
votes
2 answers

asp.net: what's the page life cycle order of a control/page compared to a user contorl inside it?

I have an aspx and inside it an ascx. From a short testing I see the PageLoad of the aspx is called before the PageLoad of the user-Control but the opposite is true for OnInit. Does someone know what is the order of the events (page compared to a…
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
25
votes
6 answers

In ASP.Net, during which page lifecycle event does viewstate get loaded?

I know it happens sometime before Load, but during what event exactly?
user9991
  • 576
  • 1
  • 5
  • 11
23
votes
5 answers

What is the 'page lifecycle' of an ASP.NET WebForm?

I'm looking to get a more thorough understanding of the ASP.NET page lifecycle. I'm in the process of building custom form controls and have found my knowledge in this area to be lacking. Are there any resources, tutorials, etc. that you've used to…
Gavin Miller
  • 43,168
  • 21
  • 122
  • 188
20
votes
6 answers

How to detect page refresh in .net

I have a Button_click event. While refreshing the page the previous Postback event is triggering again. How do I identify the page refresh event to prevent the Postback action? I tried the below code to solve it. Actually, I am adding a visual…
Srikanth
  • 683
  • 3
  • 16
  • 23
17
votes
4 answers

What happens when I press browser BACK button?

Consider the scenario: I visited a page of a website built using ASP.NET. The page is a simple aspx page containing ASP.NET server controls. I clicked on a link which takes me to some other page on the same website. I clicked the BACK button of…
Manish
  • 6,106
  • 19
  • 64
  • 90
13
votes
5 answers

Is there a function called anytime ANY page is loaded in your application?

I want to be able to run a script anytime ANY page is loaded in the application. Is there somewhere I can simply add this? Or do I have to add the code in every page load?
Hazior
  • 696
  • 4
  • 10
  • 26
12
votes
5 answers

ASP.NET : Displaying an alert from C# code-behind

I have an asp.net page with a c# code-behind. I am trying to have the code-behind display an 'alert' if the selected-index of a gridview object is changed without selecting 'confirm' or 'cancel'. The code for detecting if confirm or cancel was…
SHeinema
  • 634
  • 5
  • 14
  • 34
1
2 3
31 32