<TITLE>

  • Thread starter Thread starter Guest
  • Start date Start date
Steve B said:
Is there a way to manipulate the <TITLE> in the csharp code?

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
 
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

<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
 
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.
 
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
 
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

That's sweet Dave. Although, in Visual Studio .Net 2003 and below, adding a
runat="server" on the title attribute, as stated, will be removed by the IDE
intermitantly. It's nice that it works in .Net 2k5 now ... if it does
indeed work that way :)
 
Hi,
<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

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
 
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.

You may want to check Dave Sexton's reply...but to do it using the way I
presented (if you are using < .Net 2k5):

public class MyPage : Page
{
// ...
public string PageTitle
{
get { return "Some title"; }
}
// ...
}

HTH,
Mythran
 
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

In < .Net 2k5, the ide removes the runat and id attributes, intermitantly...

Mythran
 
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
 
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

ASP.Net 1.1 removes the runat and id attributes on the title element.

HTH,
Mythran
 
Hi,
In < .Net 2k5, the ide removes the runat and id attributes,
intermitantly...

Mythran

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
 
Hi,
Yup. That's the part of the ide that removes the attributes from the
title element.

Mythran

OK, everything is clear now. The designer in 1.1 was so messed up that
we explicitly forbade our developers to use it.

Greetings,
Laurent
 

Ask a Question

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.

Ask a Question

Back
Top