【发布时间】:2017-08-09 08:19:06
【问题描述】:
如何在不重复代码的情况下为System.Web.UI.Page 的每个实例向Page_Load() 方法添加代码?
我想要,每次页面加载,代码
Debug.WriteLine("hello");
// other stuff here
// lots of lines of code
运行。
例如,我有很多网页
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// don't want to have to repeat all that code above here
// stuff that WebForm1 does
}
}
如何为每个Page_Load 事件运行第一个 sn-p 而不为每个网络表单重复代码?
【问题讨论】:
-
在母版页加载事件中使用母版页和写入方法