{"id":106,"date":"2014-05-07T18:40:00","date_gmt":"2014-05-07T17:40:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/07\/asp-net-page-life-cycle-events\/"},"modified":"2014-05-07T18:40:00","modified_gmt":"2014-05-07T17:40:00","slug":"asp-net-page-life-cycle-events","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/07\/asp-net-page-life-cycle-events\/","title":{"rendered":"ASP.NET Page Life Cycle Events?"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>2 Minute, 11 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n<div style=\"clear: both; text-align: center;\">\n<a href=\"http:\/\/4.bp.blogspot.com\/-YfsG3FhCB7o\/U2poz05GDII\/AAAAAAAAA08\/SNL2HCGwnY0\/s1600\/pageLifeCycle.jpg\" style=\"margin-left: 1em; margin-right: 1em;\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-YfsG3FhCB7o\/U2poz05GDII\/AAAAAAAAA08\/SNL2HCGwnY0\/s1600\/pageLifeCycle.jpg\" \/><\/a><\/div>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nPreInit:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Check for the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">IsPostBack<\/code>&nbsp;property to determine whether this is the first time the page is being processed.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Create or recreate dynamic controls.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Set master page dynamically.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Set the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Theme<\/code>&nbsp;property dynamically.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Read or set profile property values.<\/li>\n<\/ul>\n<div style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px;\">\nIf Request is postback:<\/div>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">The values of the controls have not yet been restored from view state.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">If you set control property at this stage, its value might be overwritten in the next event.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nInit:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">In the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Init<\/code>&nbsp;event of the individual controls occurs first, later the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Init<\/code>&nbsp;event of the Page takes place.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This event is used to initialize control properties.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nInitComplete:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Tracking of the ViewState is turned on in this event.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Any changes made to the ViewState in this event are persisted even after the next postback.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nPreLoad:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This event processes the postback data that is included with the request.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nLoad:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">In this event the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Page<\/code>&nbsp;object calls the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">OnLoad<\/code>&nbsp;method on the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Page<\/code>&nbsp;object itself, later the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">OnLoad<\/code>&nbsp;method of the controls is called.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Thus&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Load<\/code>&nbsp;event of the individual controls occurs after the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Load<\/code>&nbsp;event of the page.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nControlEvents:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This event is used to handle specific control events such as a&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Button<\/code>&nbsp;control\u2019s&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Click<\/code>&nbsp;event or a&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">TextBox<\/code>control\u2019s&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">TextChanged<\/code>&nbsp;event.<\/li>\n<\/ul>\n<div style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px;\">\nIn case of postback:<\/div>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">If the page contains validator controls, the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Page.IsValid<\/code>&nbsp;property and the validation of the controls takes place before the firing of individual control events.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nLoadComplete:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This event occurs after the event handling stage.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This event is used for tasks such as loading all other controls on the page.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nPreRender:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">In this event the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">PreRender<\/code>&nbsp;event of the page is called first and later for the child control.<\/li>\n<\/ul>\n<div style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px;\">\nUsage:<\/div>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This method is used to make final changes to the controls on the page like assigning the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">DataSourceId<\/code>&nbsp;and calling the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">DataBind<\/code>&nbsp;method.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nPreRenderComplete:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This event is raised after each control&#8217;s&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">PreRender<\/code>&nbsp;property is completed.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nSaveStateComplete:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This is raised after the control state and view state have been saved for the page and for all controls.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nRenderComplete:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">The page object calls this method on each control which is present on the page.<\/li>\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This method writes the control\u2019s markup to send it to the browser.<\/li>\n<\/ul>\n<h4 style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px;\">\nUnload:<\/h4>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">This event is raised for each control and then for the&nbsp;<code style=\"border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;\">Page<\/code>&nbsp;object.<\/li>\n<\/ul>\n<div style=\"background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px;\">\n<b>Usage:<\/b><\/div>\n<ul style=\"background-color: white; border: 0px; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; margin: 10px 0px; padding: 0px 0px 0px 40px;\">\n<li style=\"border: 0px; margin: 0px; padding: 0px;\">Use this event in controls for final cleanup work, such as closing open database connections, closing open files, etc.<\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>PreInit: Check for the&nbsp;IsPostBack&nbsp;property to determine whether this is the first time the page is being processed. Create or recreate dynamic controls. Set master page dynamically. Set the&nbsp;Theme&nbsp;property dynamically. Read or set profile property values. If Request is postback: The values of the controls have not yet been restored from view state. If you set [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[23],"tags":[],"class_list":["post-106","post","type-post","status-publish","format-standard","hentry","category-asp-net"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"PreInit: Check for the&nbsp;IsPostBack&nbsp;property to determine whether this is the first time the page is being processed. Create or recreate dynamic controls. Set master page dynamically. Set the&nbsp;Theme&nbsp;property dynamically. Read or set profile property values. If Request is postback: The values of the controls have not yet been restored from view state. If you set&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/106"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}