using an asp.net literal inside the <title> element
This is such a simple scenario that I can't see what can possibly be going wrong. I'm using asp.net 4.0 (haven't tried older versions)
<title>Welcome to Page: <asp:Literal ID="Literal1" runat="server">
</asp:Literal></title>
When the page is rendered, the title comes out as just the contents of the literal control without the "welcome to page" text in it. If you don't believe me, try it for yourself
Can anyone explai开发者_运维技巧n?
Andy
This is not allowed in ASP.NET any of the version. No literals can be added in headsection.
But if you want to change the title Dynamically then from Code behind you can directly change the Page Title. here is the Example.
Page.Title = "Welcome to Page: Home Page";
Set it on PageLoad() using:
Page.Title = "My Page Title";
If you're doing this to set the same title on lot's of pages, do this on the MasterPage, or inherit a BasePage that does this on PageLoad().
精彩评论