471,594 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

<TITLE>

Is there a way to manipulate the <TITLEin the csharp code?

Nov 6 '06 #1
15 1800
"Steve B" <St****@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.com...
Is there a way to manipulate the <TITLEin 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
Nov 6 '06 #2


"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:12*************@corp.supernews.com...
"Steve B" <St****@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.com...
>Is there a way to manipulate the <TITLEin 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
<TITLEis 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 <titleblock, 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
Nov 6 '06 #3
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.

"Mythran" wrote:
>

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:12*************@corp.supernews.com...
"Steve B" <St****@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.com...
Is there a way to manipulate the <TITLEin 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

<TITLEis 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 <titleblock, 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
Nov 6 '06 #4
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

"Mythran" <ki********@hotmail.comwrote in message
news:OE**************@TK2MSFTNGP04.phx.gbl...
>

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:12*************@corp.supernews.com...
>"Steve B" <St****@discussions.microsoft.comwrote in message
news:59**********************************@microso ft.com...
>>Is there a way to manipulate the <TITLEin 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

<TITLEis 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 <titleblock, 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


Nov 6 '06 #5
Hi,

Mythran wrote:
<TITLEis 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
--
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
Nov 6 '06 #6


"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:et**************@TK2MSFTNGP03.phx.gbl...
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

"Mythran" <ki********@hotmail.comwrote in message
news:OE**************@TK2MSFTNGP04.phx.gbl...
>>

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:12*************@corp.supernews.com...
>>"Steve B" <St****@discussions.microsoft.comwrote in message
news:59**********************************@micros oft.com...
Is there a way to manipulate the <TITLEin 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

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


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

Nov 6 '06 #7


"Steve B" <St****@discussions.microsoft.comwrote in message
news:CB**********************************@microsof t.com...
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.

"Mythran" wrote:
>>
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
Nov 6 '06 #8
Hi Mythran,

Yes, it's a welcomed addition.

--
Dave Sexton

"Mythran" <ki********@hotmail.comwrote in message
news:ev**************@TK2MSFTNGP03.phx.gbl...
>

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:et**************@TK2MSFTNGP03.phx.gbl...
>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

"Mythran" <ki********@hotmail.comwrote in message
news:OE**************@TK2MSFTNGP04.phx.gbl...
>>>

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:12*************@corp.supernews.com...
"Steve B" <St****@discussions.microsoft.comwrote in message
news:59**********************************@micro soft.com...
Is there a way to manipulate the <TITLEin 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
<TITLEis 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 <titleblock,
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



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

Nov 6 '06 #9


"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:Om**************@TK2MSFTNGP02.phx.gbl...
Hi,

Mythran wrote:
><TITLEis 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
--
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
Nov 6 '06 #10
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


"Steve B" wrote:
Is there a way to manipulate the <TITLEin the csharp code?
Nov 6 '06 #11


"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:25**********************************@microsof t.com...
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


"Steve B" wrote:
>Is there a way to manipulate the <TITLEin the csharp code?
ASP.Net 1.1 removes the runat and id attributes on the title element.

HTH,
Mythran
Nov 6 '06 #12
Hi,

Mythran wrote:
>

"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:Om**************@TK2MSFTNGP02.phx.gbl...
>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

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
--
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
Nov 7 '06 #13


"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:ui**************@TK2MSFTNGP03.phx.gbl...
Hi,

Mythran wrote:
>>

"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:Om**************@TK2MSFTNGP02.phx.gbl...
>>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

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
--
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
Nov 7 '06 #14
Hi,

Mythran wrote:
>

"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:ui**************@TK2MSFTNGP03.phx.gbl...
>>
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

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
--
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
Nov 7 '06 #15
Then just put in an aspLiteral control in betwee the <TITLE</TITLEtags
and use that.
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Mythran" wrote:
>

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:25**********************************@microsof t.com...
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


"Steve B" wrote:
Is there a way to manipulate the <TITLEin the csharp code?

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

HTH,
Mythran
Nov 7 '06 #16

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by mark | last post: by
5 posts views Thread by Info 3000 | last post: by
3 posts views Thread by D. Alvarado | last post: by
1 post views Thread by Andreas Klemt | last post: by
6 posts views Thread by Alex | last post: by
8 posts views Thread by DC | last post: by
reply views Thread by leo001 | last post: by

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.