Showing posts with label toolbar. Show all posts
Showing posts with label toolbar. Show all posts

Tuesday, March 13, 2012

Set Page Title in code behind

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?

- NevynASP.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...
> 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
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...
> 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...
>> 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
>>
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...
> 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...
>> 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
>>
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...
> 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...
> > 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
Maybe because it's called HtmlGenericControl
and not GenericHtmlControl.

See :

http://www.csharpfriends.com/quicks...lGenericControl

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

"Nevyn Twyll" <astian@.hotmail.com> wrote in message
news:emDf1BlgFHA.1416@.TK2MSFTNGP09.phx.gbl...
>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...
>> 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...
>>> 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
>>>
>>
>>
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...
> 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...
>> 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...
>> > 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
>>>
>>