我正在开发一个性能非常重要的项目,我想永久禁用AutoEventWireup.问题在于页面和控制指令覆盖了web.config中的设置.由于此项目中将有许多协作者,因此在创建新页面和控件时不可能期望每个人都禁用它(默认情况下这是真的).有可能以某种方式执行这条规则吗?
我希望以与我对ViewState类似的方式解决这个问题 - 在所有新页面继承的基页中以编程方式将EnableViewState设置为false.但似乎没有AutoEventWireup的等价物.
覆盖支持自动事件
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
this.Init += (_o, _e) => {
this.Load += (o, e) => {
Response.Write("in page handler");
};
};
}
protected void Page_Load(object sender, EventArgs e)
{
// this handler is NOT assigned to the Load event
Response.Write("assigned by ASP .Net handler");
}
protected sealed override bool SupportAutoEvents
{
get
{
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
461 次 |
| 最近记录: |