why we use @Master type?

笑着哭i 提交于 2019-11-29 03:33:07
Lloyd

From Microsoft Docs you are defining the type of the Master property, which allows you to access the properties of your MasterPage derived class.

Provides a way to create a strongly typed reference to the ASP.NET master page when the master page is accessed from the Master property.

As an example:

this.Master.SomePublicPropertyOfMaster = Value;

Specifying the @ MasterType directive with a type of MyMasterPage results in the following property definition in the code behind class:

public new MyMasterPage Master {
  get {
    return ({MyMasterPage})base.Master;
  }
}

This property definition is created by the BuildMiscClassMembers method of the TemplateControlCodeDomTreeGenerator class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!