|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dynamic content problemI understand how to dynamically change the text of a label that appears in
the body tag by using code in the "code behind" page - one adds a <asp:label id="labelToUpdate"/> tag. However, I need to dynamically update the page title: <html> <head> <title> <------------ !!! </head> </html> VS2005 tells me that I can't place a <asp:label> here. How do I achieve this? Thanks Griff <title runat="server" id="title" />
codebehind: title.InnerText = "blah"; also, in 2.0, the @Page directive has a @title attribute, so you can probably just do Page.Title = "Heh"; karl Show quoteHide quote "Griff" <Howl***@The.Moon> wrote in message news:upHYoIQ8FHA.1484@tk2msftngp13.phx.gbl... >I understand how to dynamically change the text of a label that appears in >the body tag by using code in the "code behind" page - one adds a ><asp:label id="labelToUpdate"/> tag. > > However, I need to dynamically update the page title: > <html> > <head> > <title> <------------ !!! > </head> > </html> > > VS2005 tells me that I can't place a <asp:label> here. > > How do I achieve this? > > Thanks > > Griff > Okay
In my "base.master" file I've added: <head runat="server"> <title runat="server" id="pageTitle" /> </head> Then in my code behind page want to change the title to be something from the Request object, i.e. pageTitle = CStr(Request("ApplicationPath")) When I use the intermediate window, I can see what's in the Request object, but when I try doing this in the page load event (or the page prerender event) it's empty. Griff You need to set the InnerText property of the pageTitle object
pageTitle.InnerText = Request.ApplicationPath Show quoteHide quote "Griff" <Howl***@The.Moon> wrote in message news:OCi8XiQ8FHA.736@TK2MSFTNGP09.phx.gbl... > Okay > > In my "base.master" file I've added: > <head runat="server"> > > <title runat="server" id="pageTitle" /> > > </head> > > > Then in my code behind page want to change the title to be something from > the Request object, i.e. > pageTitle = CStr(Request("ApplicationPath")) > > When I use the intermediate window, I can see what's in the Request > object, but when I try doing this in the page load event (or the page > prerender event) it's empty. > > Griff > >
Other interesting topics
Using Components in ASP.NET (C#)
The system cannot find the file specified. (Exception from HRESULT: 0x80070002) XHTML 1.0 Retreive images stored in Access database About web.config file Can we search keywords in a word document? MS Forms 2.0 Combo box control .ascx file as index page? How to initiate a postback in a function? Problem with aspnet_wp.exe |
|||||||||||||||||||||||