469,927 Members | 1,737 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

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 3730
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 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
5 posts views Thread by Carlo Marchesoni | last post: by
15 posts views Thread by Steve B | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.