473,434 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

<TITLE>

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

Nov 6 '06 #1
15 1888
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: mark | last post by:
IF I have something like this: <title><?php print($pagetitle); ?></title> <body> <?php include("folders/my_include.php"); ?> </body> </html> and my_include.php contains the value to the...
5
by: Info 3000 | last post by:
Hi there, Simple question, but headache ! I have a PHP Page like : <HTML> <HEAD> <TITLE>Sunny day !</TITLE> </HEAD>
3
by: D. Alvarado | last post by:
Hello, I am trying to find the <TITLE> element of my document. Normally alert(document.title); works just fine, but when this statement is within a page that is a frame in a larger document,...
2
by: Irene | last post by:
Hi, I would like to modify the text within an html title tag based upon a value read from the registry (or the existence of a certain file). For example, if a certain registry value is equal...
1
by: Andreas Klemt | last post by:
Hello, I have in my strHtml a html page. so what is the fastest way (with XML Read?) to get the "myValue" between <title>myValue</title> Thanks, Andreas
6
by: Alex | last post by:
Hi, is it possible to set the title programatically from the code behind page. I placed a literal in the head section of the form and set its text property. it seemed to work bu the literal...
8
by: DC | last post by:
In HTML page, I put: <html> <head> <title>Article: <asp:Label ID="lblHTMLTitle"></asp:Label> </title> .... In the code behind: ....
1
by: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
4
by: David Thielen | last post by:
Hi; If I am using master pages, how do I set the <title> and <meta name='description' content='my title'> for each page. Obviously each page will have a different title & description. --...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.