在asp.net中此方法有什么用? [英] What is the use of this method in asp.net?

查看:54
本文介绍了在asp.net中此方法有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我asp.net中此方法的用途是什么?

Hi Could any one tell me what is the use of this method in asp.net?

protected override void OnLoad(EventArgs e)
    {
    //
    // Here we always give visitors the image.
    //
    WriteData();
    base.OnLoad(e);
    }

推荐答案

^ ]


在某些情况下,如果要扩展基类的页面,并且要在基类中执行任何常规操作所有页面的Page OnLoad事件中,因此在这种情况下,您可以使用此方法.

只是一个例子:

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);
    }
}


http://stackoverflow.com/questions/1329090/base-onloade-in-a-asp-net-page [

这篇关于在asp.net中此方法有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆