Access to the Title Element of an HTML Page
-
Is there any way of accessing the Title Element of an HTML Page from the code behind? I need a way of modifying the Text in the Title without having to go to each page on the site. Thanks for any help.
-
Is there any way of accessing the Title Element of an HTML Page from the code behind? I need a way of modifying the Text in the Title without having to go to each page on the site. Thanks for any help.
Use an inside your title tags and set its .Text property in your code behind. ;) Andrew Stone. http://andrewstone.net
-
Use an inside your title tags and set its .Text property in your code behind. ;) Andrew Stone. http://andrewstone.net
I haven't tried it yet, but thanks for the tip. This is probably the first time anyone has answered one of my questions (not that I ask many). But again, thanks for your help.
-
Use an inside your title tags and set its .Text property in your code behind. ;) Andrew Stone. http://andrewstone.net
I haven't tried it yet, but I don' think that this will work. The literal would have to be between the form tags in order to work correctly.
-
I haven't tried it yet, but I don' think that this will work. The literal would have to be between the form tags in order to work correctly.
Not at all. There is no requirement in ASP.NET for a server control to be within
form
tags to be accessible. If the control needs to participate in postback events, then it is required to be contained in the server form. For the record, I frequently use aLiteral
to set page titles, so the proposed solution should work for you. Hope that helps. :) --Jesse -
Is there any way of accessing the Title Element of an HTML Page from the code behind? I need a way of modifying the Text in the Title without having to go to each page on the site. Thanks for any help.
You can also put
<%= GetTitle() %>
in the TITLE tag, and in your code create the function which returns page's title as string (C#):public string GetTitle()
{
return "MyPage. Access tick: " + DateTime.Now.Ticks;
}Insted function you can use the property. -- Mariusz 'mAv' Wójcik master e-software engineer (BPC)