473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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?
- Nevyn
Nov 19 '05 #1
6 6303
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" <as****@hotmail.com> wrote in message
news:%2****************@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

Nov 19 '05 #2
I can't find GenericHtmlControl in the ASP.NET 1.1 docs or autocomplete.

Help?
"Daniel Fisher(lennybacon)" <in**@removethis.lennybacon.com> wrote in
message news:On**************@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" <as****@hotmail.com> wrote in message
news:%2****************@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


Nov 19 '05 #3
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)" <in**@removethis.lennybacon.com> wrote in
message news:On**************@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" <as****@hotmail.com> wrote in message
news:%2****************@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


Nov 19 '05 #4
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)" <in**@removethis.lennybacon.com> wrote in
message news:On**************@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" <as****@hotmail.com> wrote in message
news:%2****************@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


Nov 19 '05 #5
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" <as****@hotmail.com> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
I can't find GenericHtmlControl in the ASP.NET 1.1 docs or autocomplete.

Help?
"Daniel Fisher(lennybacon)" <in**@removethis.lennybacon.com> wrote in message
news:On**************@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" <as****@hotmail.com> wrote in message
news:%2****************@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



Nov 19 '05 #6
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" <pe***@nospam.rilling.net> wrote in message
news:e0**************@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)" <in**@removethis.lennybacon.com> wrote in
message news:On**************@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" <as****@hotmail.com> wrote in message
news:%2****************@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
>



Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mitch A | last post by:
What are the advantages of using inline C# code in my aspx pages (with inline I mean directly in the html between <% %>) versus code behind. It seems messy and inelegant to have code in both...
3
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
6
by: William Parker | last post by:
I have a web control I made called header.ascx. It has its own properties and methods I defined. But I cannot figure out how to access this control from my code behind page. I can create the...
14
by: Paul | last post by:
I want to set the page title and/or a form hidden field programatically through ASP.Net. I do not want to use something like... <% sTitle ="My Title" %> <html><title><%=sTitle%></title>..... ...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
1
by: LiveCycle | last post by:
Hi, I'm putting together a project that uses ASP.NET in VS2005. It uses a single master page that is responsible for most of the heavy lifting. About 90% of the 200 pages have the same...
1
by: Brock | last post by:
First note that I am using Framework 1.1. I have an .aspx page that is displaying a list of employees, but only the Employee Number, First Name, Last Name, and Title. It is working great. I...
1
by: Dave Mathew | last post by:
Is there any way to use RegisterClientScriptInclude to generate the script tags inside of the <headtag? I'm using RegisterClientScriptInclude inside of Page_Load event in the code behind for the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.