当创建一个Web控件应该重写的OnLoad或实现的Page_Load [英] When creating a web control should you override OnLoad or implement Page_Load

查看:109
本文介绍了当创建一个Web控件应该重写的OnLoad或实现的Page_Load的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您创建在Visual Studio默认情况下它一个新的Web用户控件添加Page_Load事件。什么是优势,在控制使用此,而不是重写基的OnLoad 事件?难道仅仅是的OnLoad之前的的Page_Load 事件触发

When you create a new web user control in visual studio it by default adds the Page_Load event. What is the advantage to using this rather than overriding the base OnLoad event on the control? Is it just that the Page_Load event fires before OnLoad?

推荐答案

的OnLoad 的方法应该是地方的加载事件引发。我个人总是试图处理该事件,除非我需要做各地引发事件的额外处理。

The OnLoad method should be the place where the Load event is raised. I personally always try to handle the event unless I need to do extra processing around raising the event.

我建议处理的事件本身在正常情况下。

I recommend handling the event itself under normal circumstances.

这篇关于当创建一个Web控件应该重写的OnLoad或实现的Page_Load的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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