2008: Getting to title on Master Page

Discussion in 'ASP .Net' started by bh, Dec 18, 2008.

  1. bh

    bh Guest

    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
     
    bh, Dec 18, 2008
    #1
    1. Advertising

  2. bh

    Hillbilly Guest

    Re: Getting to title on Master Page

    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"


    "bh" <> wrote in message
    news:...
    > 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
    >
    >
     
    Hillbilly, Dec 18, 2008
    #2
    1. Advertising

  3. bh wrote:
    > 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.

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    Göran Andersson, Dec 18, 2008
    #3
  4. bh

    Hillbilly Guest

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

    "Göran Andersson" <> wrote in message
    news:...
    > bh wrote:
    >> 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.
    >
    > --
    > Göran Andersson
    > _____
    > http://www.guffa.com
     
    Hillbilly, Dec 18, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug McCann
    Replies:
    1
    Views:
    1,135
    William Brogden
    Aug 5, 2004
  2. Laith Zraikat
    Replies:
    3
    Views:
    1,254
    Walter Wang [MSFT]
    Jul 6, 2006
  3. Replies:
    0
    Views:
    574
  4. Replies:
    1
    Views:
    591
    David
    Apr 24, 2007
  5. Chris Walls

    ASP.NET Master Page & Dynamic Page Title

    Chris Walls, Jul 20, 2007, in forum: ASP .Net
    Replies:
    8
    Views:
    1,239
    Chris Walls
    Jul 25, 2007
Loading...

Share This Page