How to reference a Master Page from a user control?

前端 未结 4 2133
执念已碎
执念已碎 2021-02-07 19:01

I\'m looking for a way to (preferably) strongly type a master page from a user control which is found in a content page that uses the master page.

Sadly, you can\'t use

4条回答
  •  没有蜡笔的小新
    2021-02-07 19:28

    In VB all I needed to do was change this:

    Dim lAuthLevel As Integer = Master.MasterContact.AuthenticationLevel
    

    to this:

    Dim lAuthLevel As Integer = CType(Me.Page.Master, main).MasterContact.AuthenticationLevel
    

    So all references of Master become Ctype(Me.Page.Master, typeofMaster)

    Where is in this case the word "main" - get that from the declaration at the top of the master page. e.g.

    So "main" in this case :)

提交回复
热议问题