G
Guest
Is there a way to manipulate the <TITLE> in the csharp code?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Steve B said:Is there a way to manipulate the <TITLE> in the csharp code?
Peter Duniho said:The "<TITLE>" of what? Since "<TITLE>" by itself isn't valid C# syntax,
you must be using that to refer to something else. To what are you
referring?
If you are talking about the text displayed in the title bar of the form,
then all you have to do is set the "Text" property of the form instance.
If you're talking about something else, you need to be more specific about
what it is you want to do.
Pete
Dave Sexton said:Hi Mythran,
In VS 2005 you can set a page's title in code using the Title property of
the Page object.
The property requires that a header control is present on the page, which
is added by VS 2005 when a new web page is created in the IDE. If you
need to add one yourself here is the basic html:
<html>
<head runat="server"></head> <!-- required by Title property -->
<body>...</body>
</html>
HTH

<TITLE> is html markup for the title element in aspx (or basically,
html). There is no direct way of accessing the title element from the
code-behind, and was kinda buggy using the workarounds provided on the
net (such as giving the Title id and runat attributes). What you can do
(and what we have done) is put server side script inside the <title>
block, such as the following:
<title><%=this.PageTitle%></title>
Inside your page (or base classes that your page inherits from) is
provide the PageTitle property that the server-side script is accessing.
HTH,
Mythran
Steve B said:Mythran,
Can you also send me some sample C# code on how to do this?
Are there any special "using System...." I need to add
Thanks for your help.
Laurent Bugnion said:Hi,
Just wondering, what kind of problems did you get setting
<title runat="server" id="pageTitle">Default title</title>
and accessing the control in the code-behind? It works pretty well for me.
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Peter Bromberg said:In ASP.NET 2.0, the Page class has a Title property. That's about all you
need to know. For ASP.NET 1.1, you would need to make it a runat=Server
tag
so that you can access it from the codebehind.
This is really an asp.net group topic though, not a c# language issue.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
In < .Net 2k5, the ide removes the runat and id attributes,
intermitantly...
Mythran
Laurent Bugnion said:Hi,
Interesting. We used that in our ASP.NET 1.1 application, never had any
problem with it. Did you use the HTML designer?
Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Yup. That's the part of the ide that removes the attributes from the
title element.
Mythran
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.