Home All Groups Group Topic Archive Search About
Author
24 Nov 2005 2:19 PM
Griff
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

Author
24 Nov 2005 2:25 PM
Karl Seguin
<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

--
MY ASP.Net tutorials
http://www.openmymind.net/


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
>
Are all your drivers up to date? click for free checkup

Author
24 Nov 2005 3:06 PM
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
Author
24 Nov 2005 3:34 PM
Karl Seguin
You need to set the InnerText property of the pageTitle object

pageTitle.InnerText = Request.ApplicationPath





--
MY ASP.Net tutorials
http://www.openmymind.net/


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
>
>

Bookmark and Share