Click here to Skip to main content
13,044,428 members (114,335 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 13 Jun 2012

How to skip calling Page_Load event

, 13 Jun 2012
Rate this:
Please Sign up or sign in to vote.
Difference between Page_Load and OnLoad event


In this article I am going to explain the difference between Page_Load event and OnLoad event. After you have understanding on this you will get the answer of the question "How to skip calling Page_Load" event.


OnLoad event is responsible to call Page_Load event of our page. The OnLoad function is a virtual function in the System.Web.UI.Page class so we need to override this function if we want to provide a different implementation of this function. So in page Life cycle, first OnLoad executes which in turn calls the Page_Load function. When we override the "OnLoad" function in our class, we need to call the base.OnLoad() function which in turn calls the Page_Load event. If we skip calling/writing base.OnLoad(), then our application simply won't call the Page_Load event.

Using the code 

Below is the code snippet which upon execution will skip the Page_Load event. 

using System.Web; 
public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        lblMessage.Text = "Hello World";            

    protected override void  OnLoad(EventArgs e)
        //  base.OnLoad(e);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Verma Neeru
Team Leader Nagarro
India India
I am a senior software engineer in Noida. Primarly worked in .NET,SilverLight, Prism, ASP.NET, C# etc.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
nazishrizvi11-Jun-13 17:44
membernazishrizvi11-Jun-13 17:44 
GeneralMy vote of 5 Pin
bhargavpp17-Sep-12 19:46
memberbhargavpp17-Sep-12 19:46 
QuestionAutoEventWireup="false" Pin
giammin13-Jun-12 6:21
membergiammin13-Jun-12 6:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 13 Jun 2012
Article Copyright 2012 by Verma Neeru
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid