Some times we need to change the page title of the page from the server side code. For this, there are two simple methods to set the the page title.
We can directly assign the page title form server side as Page.Title="MyPageTitle". But one main thing is that we must set the <head> tag as runat="server".
<head runat="server">
And remove the <title></title> tag from the <head> tag.
The second method is that,
put the runat="server" and id in the Title tag.
<title id="MyPageTitle" runat="server"> My Page Title </title>
After making the title tag as server control we can easily access the title from server by Id specified in the title tag. If you are using files from VS2003, then we need to declare title as protected.
protected System.Web.UI.HtmlControls.HtmlGenericControl MyPageTitle;
(Later versions of visual studio does not need this over head. The VS automatically add this declaration in designer file.)
The HtmlGenericControl type objects have a property named "InnerText" and we can set the new page title there.
MyPageTitle.InnerText="MyNewPageTitle";
Changing the Page Title from server side in ASP.NET
Related Posts:
Windows Authentication in WCF Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 … Read More
Cairngorm and MVVMNow everybody is changing to RIA(Rich Internet Application). Formally there was only one a matured platform, ie Abode Flex. But in .net framework 3.0 Microsoft came up with new technology SilverLight. After a one and half yea… Read More
new keyword in C# In C# the “new” keyword can be used in 3 different ways, as operator, modifier and constraint. We all are familiar with new operator usage, i.e. for creating object and invoking constructor. But other two usages are n… Read More
Metro Style apps METRO is our design language. We call it metro because it’s Modern and Clean. It’s Fast and in Motion. It’s about Content and Typography. And it’s entirely Authentic. - Microsoft's description of Metro. In Windows 8, one … Read More
Cannot start service from command line or a debugger. A windows service must first be installed (using installutil.exe) and....... "Cannot start service from command line or a debugger. A windows service must first be installed (using installutil.exe) and then started with ServerExplorer, Windows Services Administrative tool or the NET START command." … Read More
0 comments:
Post a Comment