【发布时间】:2011-04-10 17:39:59
【问题描述】:
通常当 Page_Load 事件处理程序被 Visual Studio 添加到代码隐藏文件时(例如,在设计器模式下双击页面),它最终看起来像这样:
/// <summary>
/// Handles the Load event of the Page control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void Page_Load(object sender, EventArgs e)
{
// ...
}
但 Resharper 建议使用 Name 'Page_Load' does not match rule 'Methods, properties and events'. Suggested name is 'PageLoad'。我猜有更好的方法来定义页面加载处理程序,但我不记得语法是什么,但我想它会解决这个 Resharper 警告?
可能是这样的:
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// ...
}
但我似乎记得OnLoad 和PageLoad 不完全相同?
【问题讨论】:
标签: naming-conventions resharper pageload