2008: Getting to title on Master Page

B

bh

I'm getting strange behavior, while trying to edit page titles from content
pages.

On the master page, I have a label control, named lblTitle, between the
<title></title> tags

On the content page, I have a page-level variable declared: Dim lblTitle as
Label

On Load, I have:
lblTitle = CType(Master.FindControl("lblTitle"), Label)
lblTitle.Text = "My page title"

When I run application, the title bar of the content page shows:
<span id="ctl00_lblTitle">My page title</span>

How can I have customized titles for each page, without the <span> tags
showing? I'm not even sure where those span tags are generated. Thanks in
advance.

bh
 
H

Hillbilly

None of that is necessary.
We can name or change a Page title on demand in the Page_Load event handler
of each content page...

Page.Title = "Page Title"
 
G

Göran Andersson

bh said:
I'm getting strange behavior, while trying to edit page titles from content
pages.

On the master page, I have a label control, named lblTitle, between the
<title></title> tags

On the content page, I have a page-level variable declared: Dim lblTitle as
Label

On Load, I have:
lblTitle = CType(Master.FindControl("lblTitle"), Label)
lblTitle.Text = "My page title"

When I run application, the title bar of the content page shows:
<span id="ctl00_lblTitle">My page title</span>

How can I have customized titles for each page, without the <span> tags
showing? I'm not even sure where those span tags are generated. Thanks in
advance.

bh

The span tags comes trom the Label control, that is how it's rendered.
If you want literal text instead of a label, use a Literal control
instead of a Label control.

If you have runat="server" in the head tag, you can access the title
using the Page.Title property, just as Hillbilly showed.
 
H

Hillbilly

I forgot to mention adding runat but our good friend the compiler would
remind him anyway ;-)
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top