通常,当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
不完全相同?