How to set Page's Title from a web content page in ASP.NET 3.5

后端 未结 7 1444
长情又很酷
长情又很酷 2021-02-15 07:52

I\'ve read through quite a bit of posts/articles on how to do this and I still am not getting the page title set from the content page. My pages render OK except I can\'t get th

7条回答
  •  爱一瞬间的悲伤
    2021-02-15 08:35

    So what needs to happen is this

    MasterPage.Master

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Me.Page.Title = "Dynamically set in Master page"
    End Sub
    

    Default.aspx

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Page.Title = "Dynamically set in ASPX page"
    End Sub
    

    This way your master page title is set BEFORE your content page title. If you do not set a title from the content page, the masterpage will be the default title. If you do set a title from the content page, then it will override it.

提交回复
热议问题