How to control elements on a asp.net master page from child page

前端 未结 5 1716
野趣味
野趣味 2020-12-08 12:33

I have a few pages on my asp.net website that I would like to turn off a control on the master page. Is there a way to communicate with the master page from a child page?

5条回答
  •  悲哀的现实
    2020-12-08 13:10

    You need to use a MasterType directive in your page markup

    <%@ MasterType TypeName="Namespace.Etc.MyMasterPage" %>
    

    Then you will be able to access any public properties of the page's master page using

    this.Master.PropertyIWantToIntefereWith...
    

    Hope this helps

提交回复
热议问题