473,387 Members | 1,492 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,387 software developers and data experts.

Label in <title>

DC
In HTML page, I put:

<html>
<head>
<title>Article: <asp:Label ID="lblHTMLTitle"></asp:Label> </title>
....

In the code behind:

....
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblHTMLTitle As System.Web.UI.WebControls.Label
....
cmdSQL = New SqlCommand(sSQL, connADO)
connADO.Open()
cmdReader = cmdSQL.ExecuteReader
If cmdReader.Read() Then
lblHTMLTitle.Text = cmdReader.Item("Title").ToString()
...
.....

But each time it hits: lblHTMLTitle.Text =
cmdReader.Item("Title").ToString(), it gives me the following error message:
Object reference not set to an instance of an object.

Any ideas why is this happening?

Or can't <asp:label> put in <title> tag?
Nov 18 '05 #1
8 3946
instead of using label in <title>
set the title as
<title id=myPageTitle>

in code behind..
System.Web.UI.HtmlGenericControl myPageTitle;

in page load
if(!Page.IsPostBack)
{
myPageTitle.InnerText = "My Page title is dynamic";
}

try something like this....

--

Regards,

HD
"DC" <nemo_HATE_SPAM@computermail_FREESPAM.net> wrote in message
news:Om**************@tk2msftngp13.phx.gbl...
In HTML page, I put:

<html>
<head>
<title>Article: <asp:Label ID="lblHTMLTitle"></asp:Label> </title>
...

In the code behind:

...
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblHTMLTitle As System.Web.UI.WebControls.Label
...
cmdSQL = New SqlCommand(sSQL, connADO)
connADO.Open()
cmdReader = cmdSQL.ExecuteReader
If cmdReader.Read() Then
lblHTMLTitle.Text = cmdReader.Item("Title").ToString()
...
....

But each time it hits: lblHTMLTitle.Text =
cmdReader.Item("Title").ToString(), it gives me the following error message: Object reference not set to an instance of an object.

Any ideas why is this happening?

Or can't <asp:label> put in <title> tag?

Nov 18 '05 #2
You can get/set the page title through code by adding the runat="server"
attribute to your title tag.
Here's a good example:
http://www.aspalliance.com/kenc/faq5.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"DC" <nemo_HATE_SPAM@computermail_FREESPAM.net> wrote in message
news:Om**************@tk2msftngp13.phx.gbl...
In HTML page, I put:

<html>
<head>
<title>Article: <asp:Label ID="lblHTMLTitle"></asp:Label> </title>
...

In the code behind:

...
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblHTMLTitle As System.Web.UI.WebControls.Label
...
cmdSQL = New SqlCommand(sSQL, connADO)
connADO.Open()
cmdReader = cmdSQL.ExecuteReader
If cmdReader.Read() Then
lblHTMLTitle.Text = cmdReader.Item("Title").ToString()
...
....

But each time it hits: lblHTMLTitle.Text =
cmdReader.Item("Title").ToString(), it gives me the following error message: Object reference not set to an instance of an object.

Any ideas why is this happening?

Or can't <asp:label> put in <title> tag?

Nov 18 '05 #3
Hermit Dave wrote:
instead of using label in <title>
set the title as
<title id=myPageTitle>

in code behind..
System.Web.UI.HtmlGenericControl myPageTitle;

in page load
if(!Page.IsPostBack)
{
myPageTitle.InnerText = "My Page title is dynamic";
}

try something like this....


Don't forget that the <title> tag needs a runat="server" attribute:

<title id="myPageTitle" runat="server">

--
mikeb
Nov 18 '05 #4
oh shite.. forgot that... sorry... was about to leave for home then...

--
Regards,

HD

Once a Geek.... Always a Geek
"mikeb" <ma************@mailnull.com> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
Hermit Dave wrote:
instead of using label in <title>
set the title as
<title id=myPageTitle>

in code behind..
System.Web.UI.HtmlGenericControl myPageTitle;

in page load
if(!Page.IsPostBack)
{
myPageTitle.InnerText = "My Page title is dynamic";
}

try something like this....


Don't forget that the <title> tag needs a runat="server" attribute:

<title id="myPageTitle" runat="server">

--
mikeb

Nov 18 '05 #5
I dont know about anyone else..but it seems like VS.Net always removed my
runat="server" attribute on my title tag...I've stopped doing it that way
and use a placeholder now instead...

Chad Mccune, MCSE, MCDBA

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
You can get/set the page title through code by adding the runat="server"
attribute to your title tag.
Here's a good example:
http://www.aspalliance.com/kenc/faq5.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"DC" <nemo_HATE_SPAM@computermail_FREESPAM.net> wrote in message
news:Om**************@tk2msftngp13.phx.gbl...
In HTML page, I put:

<html>
<head>
<title>Article: <asp:Label ID="lblHTMLTitle"></asp:Label> </title>
...

In the code behind:

...
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblHTMLTitle As System.Web.UI.WebControls.Label
...
cmdSQL = New SqlCommand(sSQL, connADO)
connADO.Open()
cmdReader = cmdSQL.ExecuteReader
If cmdReader.Read() Then
lblHTMLTitle.Text = cmdReader.Item("Title").ToString()
...
....

But each time it hits: lblHTMLTitle.Text =
cmdReader.Item("Title").ToString(), it gives me the following error

message:
Object reference not set to an instance of an object.

Any ideas why is this happening?

Or can't <asp:label> put in <title> tag?


Nov 18 '05 #6
DC
Thanks. How about changing meta content?
Can it be done from server side as well?

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:eb****************@TK2MSFTNGP12.phx.gbl...
You can get/set the page title through code by adding the runat="server"
attribute to your title tag.
Here's a good example:
http://www.aspalliance.com/kenc/faq5.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"DC" <nemo_HATE_SPAM@computermail_FREESPAM.net> wrote in message
news:Om**************@tk2msftngp13.phx.gbl...
In HTML page, I put:

<html>
<head>
<title>Article: <asp:Label ID="lblHTMLTitle"></asp:Label> </title>
...

In the code behind:

...
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblHTMLTitle As System.Web.UI.WebControls.Label
...
cmdSQL = New SqlCommand(sSQL, connADO)
connADO.Open()
cmdReader = cmdSQL.ExecuteReader
If cmdReader.Read() Then
lblHTMLTitle.Text = cmdReader.Item("Title").ToString()
...
....

But each time it hits: lblHTMLTitle.Text =
cmdReader.Item("Title").ToString(), it gives me the following error

message:
Object reference not set to an instance of an object.

Any ideas why is this happening?

Or can't <asp:label> put in <title> tag?


Nov 18 '05 #7
sorry mate was in a bit of hurry... my bad..
thanks for correcting...

--
Regards,

HD

Once a Geek.... Always a Geek
"mikeb" <ma************@mailnull.com> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
Hermit Dave wrote:
instead of using label in <title>
set the title as
<title id=myPageTitle>

in code behind..
System.Web.UI.HtmlGenericControl myPageTitle;

in page load
if(!Page.IsPostBack)
{
myPageTitle.InnerText = "My Page title is dynamic";
}

try something like this....


Don't forget that the <title> tag needs a runat="server" attribute:

<title id="myPageTitle" runat="server">

--
mikeb

Nov 18 '05 #8
yep , same here , a real pita , have to reinsert the runat="server" anytime
the page ( code behind I believe ? ) is edited and saved.

"Chad McCune" <mccuneca@_NOSPAM_fpwk.com> wrote in message
news:ua**************@TK2MSFTNGP10.phx.gbl...
I dont know about anyone else..but it seems like VS.Net always removed my
runat="server" attribute on my title tag...I've stopped doing it that way
and use a placeholder now instead...

Chad Mccune, MCSE, MCDBA

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
You can get/set the page title through code by adding the runat="server"
attribute to your title tag.
Here's a good example:
http://www.aspalliance.com/kenc/faq5.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"DC" <nemo_HATE_SPAM@computermail_FREESPAM.net> wrote in message
news:Om**************@tk2msftngp13.phx.gbl...
In HTML page, I put:

<html>
<head>
<title>Article: <asp:Label ID="lblHTMLTitle"></asp:Label> </title>
...

In the code behind:

...
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Protected WithEvents lblHTMLTitle As System.Web.UI.WebControls.Label ...
cmdSQL = New SqlCommand(sSQL, connADO)
connADO.Open()
cmdReader = cmdSQL.ExecuteReader
If cmdReader.Read() Then
lblHTMLTitle.Text = cmdReader.Item("Title").ToString()
...
....

But each time it hits: lblHTMLTitle.Text =
cmdReader.Item("Title").ToString(), it gives me the following error

message:
Object reference not set to an instance of an object.

Any ideas why is this happening?

Or can't <asp:label> put in <title> tag?



Nov 18 '05 #9

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...
5
by: Carlo Marchesoni | last post by:
Is it possible to change the document's title property from code behind (c#) ? I need to build a dynamic title at runtime.
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. --...
15
by: Steve B | last post by:
Is there a way to manipulate the <TITLEin the csharp code?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.