Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Could any one tell me what is the use of this method in asp.net?
C#
protected override void OnLoad(EventArgs e)
    {
    //
    // Here we always give visitors the image.
    //
    WriteData();
    base.OnLoad(e);
    }
Posted

RTFM[^]
 
Share this answer
 
In some situation if you want to extend your pages with the base class and in the base class you want to perform any common operation in Page OnLoad event for all pages so in that case you can use this method.

It's just an example:

public class WebForm1 : MyBaseClass
{
    private void Page_Load(object sender, System.EventArgs e)
    {

    } 
}

public class MyBaseClass : System.Web.UI.Page
{
    protected override void OnLoad(EventArgs e)
    {
       // ... add custom logic here ...

       // Be sure to call the base class OnLoad method!
       base.OnLoad(e);
    }
}
 
Share this answer
 
v2
Comments
R. Giskard Reventlov 26-Jul-11 6:14am    
That's not what he asked at all - he probably wants to know what WriteData() does but posed the question poorly.
Parwej Ahamad 26-Jul-11 6:17am    
Oh ok :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900