Connecting Tech Pros Worldwide Forums | Help | Site Map

Set Page Title in code behind

Nevyn Twyll
Guest
 
Posts: n/a
#1: Nov 19 '05
In my code behind page, I want to dynamically set the page title of my page
(the one that shows on IE's toolbar). How do I do that?


- Nevyn



Daniel Fisher\(lennybacon\)
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Set Page Title in code behind


ASP.NET 1.1

in webform:
....
<title ID="HtmlTitle" runat="server></title>
....

in codebehind:
....
protected GenericHtmlControl HtmlTitle;
....
void Page_Load(...){
this.HtmlTitle.Value = "blabla";
....

--Daniel Fisher(lennybacon)

"Nevyn Twyll" <astian@hotmail.com> wrote in message
news:%23axxS0kgFHA.2560@TK2MSFTNGP10.phx.gbl...[color=blue]
> In my code behind page, I want to dynamically set the page title of my
> page (the one that shows on IE's toolbar). How do I do that?
>
>
> - Nevyn
>[/color]


Nevyn Twyll
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Set Page Title in code behind


I can't find GenericHtmlControl in the ASP.NET 1.1 docs or autocomplete.

Help?


"Daniel Fisher(lennybacon)" <info@removethis.lennybacon.com> wrote in
message news:Onljv5kgFHA.2156@TK2MSFTNGP14.phx.gbl...[color=blue]
> ASP.NET 1.1
>
> in webform:
> ...
> <title ID="HtmlTitle" runat="server></title>
> ...
>
> in codebehind:
> ...
> protected GenericHtmlControl HtmlTitle;
> ...
> void Page_Load(...){
> this.HtmlTitle.Value = "blabla";
> ...
>
> --Daniel Fisher(lennybacon)
>
> "Nevyn Twyll" <astian@hotmail.com> wrote in message
> news:%23axxS0kgFHA.2560@TK2MSFTNGP10.phx.gbl...[color=green]
>> In my code behind page, I want to dynamically set the page title of my
>> page (the one that shows on IE's toolbar). How do I do that?
>>
>>
>> - Nevyn
>>[/color]
>
>[/color]


Nevyn Twyll
Guest
 
Posts: n/a
#4: Nov 19 '05

re: Set Page Title in code behind


Ah. Did you mean HtmlGenericControl?

Here's what I did that worked

System.Web.UI.HtmlControls.HtmlGenericControl HtmlTitle;

HtmlTitle = (HtmlGenericControl) FindControl("htmltitle");

HtmlTitle.InnerText = "What I want it to say";

"Daniel Fisher(lennybacon)" <info@removethis.lennybacon.com> wrote in
message news:Onljv5kgFHA.2156@TK2MSFTNGP14.phx.gbl...[color=blue]
> ASP.NET 1.1
>
> in webform:
> ...
> <title ID="HtmlTitle" runat="server></title>
> ...
>
> in codebehind:
> ...
> protected GenericHtmlControl HtmlTitle;
> ...
> void Page_Load(...){
> this.HtmlTitle.Value = "blabla";
> ...
>
> --Daniel Fisher(lennybacon)
>
> "Nevyn Twyll" <astian@hotmail.com> wrote in message
> news:%23axxS0kgFHA.2560@TK2MSFTNGP10.phx.gbl...[color=green]
>> In my code behind page, I want to dynamically set the page title of my
>> page (the one that shows on IE's toolbar). How do I do that?
>>
>>
>> - Nevyn
>>[/color]
>
>[/color]


Peter Rilling
Guest
 
Posts: n/a
#5: Nov 19 '05

re: Set Page Title in code behind


Just a word of caution with this though. Sometimes when you switch between
the designer and the HTML view, the <title> tag is reset such that the
@runat attribute is removed.

"Daniel Fisher(lennybacon)" <info@removethis.lennybacon.com> wrote in
message news:Onljv5kgFHA.2156@TK2MSFTNGP14.phx.gbl...[color=blue]
> ASP.NET 1.1
>
> in webform:
> ...
> <title ID="HtmlTitle" runat="server></title>
> ...
>
> in codebehind:
> ...
> protected GenericHtmlControl HtmlTitle;
> ...
> void Page_Load(...){
> this.HtmlTitle.Value = "blabla";
> ...
>
> --Daniel Fisher(lennybacon)
>
> "Nevyn Twyll" <astian@hotmail.com> wrote in message
> news:%23axxS0kgFHA.2560@TK2MSFTNGP10.phx.gbl...[color=green]
> > In my code behind page, I want to dynamically set the page title of my
> > page (the one that shows on IE's toolbar). How do I do that?
> >
> >
> > - Nevyn
> >[/color]
>
>[/color]


Juan T. Llibre
Guest
 
Posts: n/a
#6: Nov 19 '05

re: Set Page Title in code behind


Maybe because it's called HtmlGenericControl
and not GenericHtmlControl.

See :

http://www.csharpfriends.com/quickst...GenericControl



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaņol
Ven, y hablemos de ASP.NET...
======================

"Nevyn Twyll" <astian@hotmail.com> wrote in message
news:emDf1BlgFHA.1416@TK2MSFTNGP09.phx.gbl...[color=blue]
>I can't find GenericHtmlControl in the ASP.NET 1.1 docs or autocomplete.
>
> Help?
>
>
> "Daniel Fisher(lennybacon)" <info@removethis.lennybacon.com> wrote in message
> news:Onljv5kgFHA.2156@TK2MSFTNGP14.phx.gbl...[color=green]
>> ASP.NET 1.1
>>
>> in webform:
>> ...
>> <title ID="HtmlTitle" runat="server></title>
>> ...
>>
>> in codebehind:
>> ...
>> protected GenericHtmlControl HtmlTitle;
>> ...
>> void Page_Load(...){
>> this.HtmlTitle.Value = "blabla";
>> ...
>>
>> --Daniel Fisher(lennybacon)
>>
>> "Nevyn Twyll" <astian@hotmail.com> wrote in message
>> news:%23axxS0kgFHA.2560@TK2MSFTNGP10.phx.gbl...[color=darkred]
>>> In my code behind page, I want to dynamically set the page title of my page (the one
>>> that shows on IE's toolbar). How do I do that?
>>>
>>>
>>> - Nevyn
>>>[/color]
>>
>>[/color]
>
>[/color]


Lars-Erik Aabech
Guest
 
Posts: n/a
#7: Nov 19 '05

re: Set Page Title in code behind


To get around the IDE rewriting of the <title runat="server".. stuff, I
usually put a literal control inside the title tag.
Like:
<title><asp:Literal runat="Server" id="litTitle"/></title>

If you insert this in HTML view, and swap to design view, you get the member
field automagically, and can set it's Text property in ie. Page_Load.. :)

Lars-Erik

"Peter Rilling" <peter@nospam.rilling.net> wrote in message
news:e0hvkJlgFHA.2840@tk2msftngp13.phx.gbl...[color=blue]
> Just a word of caution with this though. Sometimes when you switch
> between
> the designer and the HTML view, the <title> tag is reset such that the
> @runat attribute is removed.
>
> "Daniel Fisher(lennybacon)" <info@removethis.lennybacon.com> wrote in
> message news:Onljv5kgFHA.2156@TK2MSFTNGP14.phx.gbl...[color=green]
>> ASP.NET 1.1
>>
>> in webform:
>> ...
>> <title ID="HtmlTitle" runat="server></title>
>> ...
>>
>> in codebehind:
>> ...
>> protected GenericHtmlControl HtmlTitle;
>> ...
>> void Page_Load(...){
>> this.HtmlTitle.Value = "blabla";
>> ...
>>
>> --Daniel Fisher(lennybacon)
>>
>> "Nevyn Twyll" <astian@hotmail.com> wrote in message
>> news:%23axxS0kgFHA.2560@TK2MSFTNGP10.phx.gbl...[color=darkred]
>> > In my code behind page, I want to dynamically set the page title of my
>> > page (the one that shows on IE's toolbar). How do I do that?
>> >
>> >
>> > - Nevyn
>> >[/color]
>>
>>[/color]
>
>[/color]


Closed Thread