I want to get the page title in c# master page code behind.
I tried using Page.Header.Title;
property but it return null
.
Please help me to get the title.
Thanks in advance.
Shibin V.M
I want to get the page title in c# master page code behind.
I tried using Page.Header.Title;
property but it return null
.
Please help me to get the title.
Thanks in advance.
Shibin V.M
In your page head include runat="server"
then you can easily get the Page title by
string Title = Page.Title;
EDIT:
Using the Title property of Page requires a header control on the page. (e.g. <head runat="server" />
).
You can set the page title on Page_Load Event like this
protected void Page_Load(object sender, EventArgs e)
{ Page.Title = "Page Title"; }
and get the page title using
string title = Page.Title;
try this in your master page
string Title = "Your Site: " + this.Page.Title;
Set Title
attribute of content pages <%@ Page Title="Contact us" ../>
and handle the Master page's Load or Init event to get Page.Title
or Page.Header.Title
.
Use this in your html tag, it has worked for me <%: Page.Title %>
.
For eg: <li class="active"><%: Page.Title %></li>
.
© 2022 - 2024 — McMap. All rights reserved.