By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,825 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,825 IT Pros & Developers. It's quick & easy.

Sorry for simple question:

P: n/a
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux
Nov 18 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Check out this faq,
http://authors.aspalliance.com/kenc/faq5.aspx

-Saravana
www.ExtremeExperts.com

"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux

Nov 18 '05 #2

P: n/a
Hi Wardeaux,

Put a Web control between your <title> and </title> tags, then you could
reference that control from your codebehind to manipulate its output. (tip:
use the Literal web control)
Regards,
Nils Magnus Englund

"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux

Nov 18 '05 #3

P: n/a
..aspx.cs
protected string _title;
_title = "Hello";
..aspx
<head>
<title><%=_title%></title>
</head>

MattC
"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux

Nov 18 '05 #4

P: n/a
VS.NET 2003 has a bug that will remove runat="server" from
the <title> element when switching from design to code views.

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux

Nov 18 '05 #5

P: n/a
ehgads no...far better off to use the above suggestion, namely <title
runat="server" id="title" />

and

protected HtmlGenericControl title;
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"MattC" <m@m.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
.aspx.cs
protected string _title;
_title = "Hello";
.aspx
<head>
<title><%=_title%></title>
</head>

MattC
"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux


Nov 18 '05 #6

P: n/a
Check out:
http://aspnet101.com/titlechange.asp...tlechange.aspx

David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux

Nov 18 '05 #7

P: n/a
hey don't be sorry for asking this, this was also my first headache when
starting .Net and the reason is it requires quite a good knowledge of what's
really going on behind the curtains in .Net !

"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux

Nov 18 '05 #8

P: n/a
HTML for your aspx
<title id="PageTitle" runat="server">My Page Title</Title>

code behind
Dim title As HtmlContainerControl
title = DirectCast(FindControl("PageTitle"), HtmlContainerControl)
title.InnerText = "My New Page Title"

HTH
Craig

"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux

Nov 18 '05 #9

P: n/a
I use VS 2003 and runat="server" on my title tags with no problems, and I
constantly switch between design and code views.

Craig

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
VS.NET 2003 has a bug that will remove runat="server" from
the <title> element when switching from design to code views.

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux


Nov 18 '05 #10

P: n/a
I'd say you were a lucky freak of nature :-) as it happens to me
with regularity. There are discussions in newsgroups, forums, and
blogs that discovered and discuss this VS2003 bug.

<%= Clinton Gallagher
"Craig" <us**@domain.com> wrote in message
news:Dg*******************@tornado.tampabay.rr.com ...
I use VS 2003 and runat="server" on my title tags with no problems, and I
constantly switch between design and code views.

Craig

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
VS.NET 2003 has a bug that will remove runat="server" from
the <title> element when switching from design to code views.

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
OK... how do I set the aspx page html title from my codebehind?
MTIA
wardeaux



Nov 18 '05 #11

P: n/a

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Iz*****************@twister.rdc-kc.rr.com...
I'd say you were a lucky freak of nature :-) as it happens to me
with regularity.


As a good friend tells me all the time, luck is the residue of good design.
:-) I have three development boxes on which I have never experienced this
bug. Do you have the Automatic Formatting and HTML Validation "features"
enabled for your html editor? I have mine turned off becuase quite frankly
they're stupid, and they wreck more than they fix.
Nov 18 '05 #12

P: n/a
Uncle Chutney loves your friend's proverb:

"Luck is the residue of good design."

He asked me to let you know.

--
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Craig" <us**@domain.com> wrote in message
news:kh******************@tornado.tampabay.rr.com. ..

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Iz*****************@twister.rdc-kc.rr.com...
I'd say you were a lucky freak of nature :-) as it happens to me
with regularity.
As a good friend tells me all the time, luck is the residue of good

design. :-) I have three development boxes on which I have never experienced this
bug. Do you have the Automatic Formatting and HTML Validation "features"
enabled for your html editor? I have mine turned off becuase quite frankly they're stupid, and they wreck more than they fix.

Nov 18 '05 #13

P: n/a
You shouldn't be having trouble with this, but if you are - here's a
workaround:
declare a protected string in your codebehind with page scope
called, say, strTitle
Your title tag: <title><%=strTitle%></title> will render the
contents of this string which you can set anytime before page_unload.

Gerry

"Craig" <us**@domain.com> wrote in message
news:Dg*******************@tornado.tampabay.rr.com ...
I use VS 2003 and runat="server" on my title tags with no problems, and I
constantly switch between design and code views.

Craig

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
VS.NET 2003 has a bug that will remove runat="server" from
the <title> element when switching from design to code views.

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
"Wardeaux" <wa******@bellsouth.net> wrote in message
news:Ou**************@TK2MSFTNGP14.phx.gbl...
> OK... how do I set the aspx page html title from my codebehind?
> MTIA
> wardeaux
>
>



Nov 18 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.