Print Page | Close Window

dynamic title head

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=284
Printed Date: 28 March 2026 at 4:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: dynamic title head
Posted By: CountAnton
Subject: dynamic title head
Date Posted: 18 February 2003 at 10:00am

Is their a simple way to reference the <title> tag as a html control so that the text it contains can be entered programatically?

It was easy enough to do this when I had the code in the same file as the html content, but I have since started using codebehind to put the code in a 'aspx.cs' file.  All the other web controls ended up having to be declared as something like...

protected System.Web.UI.WebControls.Label Heading;

But I can't seem to find any equivelent for the title tag.  Is there one?



-------------
Anton Channing
http://www.kiamagic.com



Replies:
Posted By: MorningZ
Date Posted: 20 February 2003 at 7:36am
you could move the heading into a user control and set it there

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: CountAnton
Date Posted: 24 February 2003 at 8:07am

Originally posted by MorningZ MorningZ wrote:

you could move the heading into a user control and set it there

Okay, thanks, I guess I will have to do it this way.  Was just wondering if their was a simple way like with other html elements.  Apparently MicroSoft have neglected the tags in the <head></head> in ASP.NET.

Do you know if there is an efficiency issue using some of the predefined controls compared to custom controls?  In other words are the predefined controls trying to do anything clever that impedes performance, that writing our own controls could improve?



-------------
Anton Channing
http://www.kiamagic.com


Posted By: MorningZ
Date Posted: 24 February 2003 at 8:14am
i'm not sure 100%.. but if i had to make an educated guess, i would say it wouldn't be much different since it all gets compiled anyways.... if there even was any difference, it wouldn't be noticible

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: CountAnton
Date Posted: 24 February 2003 at 8:29am

Originally posted by MorningZ MorningZ wrote:

i'm not sure 100%.. but if i had to make an educated guess, i would say it wouldn't be much different since it all gets compiled anyways.... if there even was any difference, it wouldn't be noticible

Okay, thanks.  Maybe one day they will add a standard control for manipulating tags within the head.  In the meantime I guess we all have to keep re-inventing the wheel...



-------------
Anton Channing
http://www.kiamagic.com


Posted By: MorningZ
Date Posted: 24 February 2003 at 2:11pm
maybe you can help me out the other direction....

where are you learning about code behind and stuff at? i am still hazy on using it and cannot find really good examples/explainations about it....

i think its more a matter of me thinking its so complex and hard, when it's really not, but some good code would be equivelent of dropping an anvil on my head to make me stop thinking its so complex, heh heh

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: CountAnton
Date Posted: 25 February 2003 at 8:14am

A basic code behind tutorial can be found at...

http://www.4guysfromrolla.com/webtech/100500-1.shtml - http://www.4guysfromrolla.com/webtech/100500-1.shtml

its not really much different than not doing it.  The only real differences being

a) that you need to put a directive at the top of the aspx page, telling it where its code is

b) in the code file you need to declare all the controls that you use

c) you cannot directly access html tags simply by giving them an id and a runat="server".  You have to create custom controls instead.

d) you precompile the code into a dll.  Visual Studio makes this last step pretty easy.  Not sure how you'd go about it from the command line, since it puts all the pages into a single dll with the name of your web project and I only have experience of compiling from a single source on the command line.

If I'm wrong about any of this I'd like to know...



-------------
Anton Channing
http://www.kiamagic.com


Posted By: niner911
Date Posted: 27 February 2003 at 4:39pm

you can also just use the "literal" control for the <head></head> stuff. this is the approach i took on my wite.

 



Posted By: CountAnton
Date Posted: 03 March 2003 at 9:32am

Originally posted by niner911 niner911 wrote:

you can also just use the "literal" control for the <head></head> stuff. this is the approach i took on my wite.

Okay, thanks.  Didn't know about the literal control, that will probably be useful at some point.  I have since created a custom control, and this serves my purposes better because I can include all the meta tags in it so they always get included.  Also, links to user specific style sheets can easilly be added in a custom control.



-------------
Anton Channing
http://www.kiamagic.com


Posted By: syrik
Date Posted: 17 June 2003 at 10:22am

This is how I do it.

Response.Write("<title>Hello World</title>")




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net