I want to get the page title in the code of the C # main page.
I tried using the Page.Header.Title; property Page.Header.Title; but it returns null .
Page.Header.Title;
null
Please help me get the title.
Thanks in advance.
Shibin V.M.
In the page title runat="server" you can easily get the page title
runat="server"
string Title = Page.Title;
EDIT:
Using the Title property for a page requires managing the title on the page. (for example, <head runat="server" /> ).
<head runat="server" />
You can set the page title in a 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 on the main page
string Title = "Your Site: " + this.Page.Title;
Set the Title attribute of the content pages <%@ Page Title="Contact us" ../> and process the start page of Load or Init to get Page.Title or Page.Header.Title .
Title
<%@ Page Title="Contact us" ../>
Page.Title
Page.Header.Title
Use this in the html tag, it worked for me <%: Page.Title %> .For example: <li class="active"><%: Page.Title %></li> .
<%: Page.Title %>
<li class="active"><%: Page.Title %></li>
Source: https://habr.com/ru/post/901786/More articles:How to change the root package of a project project Lift? - scalaORA-02289: sequence does not exist when upgrading Hibernate 3 to sleep mode 4 - javaRemote form Rails and select if the changes do not work. - ruby-on-railsWhat is the definition of a βtrueβ multidimensional array and what languages ββsupport them? - language-agnosticHow to configure ColdFusion ORM for multi-session DSN? - coldfusionCreating Dashboards in Django - djangoJava: how to distinguish between false awakening and timeout while waiting () - javaWhat is the difference between this.GetType (). Assembly.GetName (). Version and Assembly.GetExecutingAssembly (). GetName (). Version? - c #How to display popup image at boot time - androidCreating an instance of a C ++ template depending on the if-c ++ clauseAll Articles