Changing the document.title from a user control

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, May 23, 2005.

  1. I would like to change the <title></title> of a page from a user control. I
    have been unable to find any property in VB that allows me to do this. The
    only thing I have been able to find that might be related is when in Design
    view, there is a property called title under the DOCUMENT object in
    properties, which leads me to believe that there may be a way to access a
    DOCUMENT.title somewhere (although that may be only for Javascript/JScript).
    Does anyone know of a way to change the document title programmatically
    using VB.NET in ASP.NET from a User Control? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, May 23, 2005
    #1
    1. Advertising

  2. Nathan Sokalski

    Cor Ligthert Guest

    Cor Ligthert, May 23, 2005
    #2
    1. Advertising

  3. Hi,

    To be able to change the page title from an asp.net application add the
    following to html portion of the aspx.

    <HEAD>
    <title runat="server" id="PageTitle"></title>
    ......
    </HEAD>

    Note that if you make changes to the web page vb.net will drop the
    runat=server. Make sure you add it back in or you wont be able to change the
    page title

    Add the following to the aspx.vb file

    Protected PageTitle as new htmlgenericcontrol

    To change the page title from the page

    PageTitle.InnerText= "My new page title"

    To access this from a user control

    Dim pagetitle as htmlgenericcontrol

    Try
    pagetitle=ctype(me.page.findcontrol("PageTitle"), htmlgenericcontrol)
    pagetitle.innertext="Live from user control"
    catch
    end try

    Ken
    ------------------------

    "Nathan Sokalski" wrote:

    > I would like to change the <title></title> of a page from a user control. I
    > have been unable to find any property in VB that allows me to do this. The
    > only thing I have been able to find that might be related is when in Design
    > view, there is a property called title under the DOCUMENT object in
    > properties, which leads me to believe that there may be a way to access a
    > DOCUMENT.title somewhere (although that may be only for Javascript/JScript).
    > Does anyone know of a way to change the document title programmatically
    > using VB.NET in ASP.NET from a User Control? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    >
    >
     
    Ken Tucker [MVP], May 23, 2005
    #3
    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. Andreas Klemt
    Replies:
    1
    Views:
    482
    Steve C. Orr, MCSD
    Aug 10, 2003
  2. =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=

    Changing document.title

    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=, Jul 7, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    574
    Edward
    Jul 7, 2004
  3. Nathan Sokalski

    Changing the document.title from a user control

    Nathan Sokalski, May 23, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,114
    =?Utf-8?B?S2VuIFR1Y2tlciBbTVZQXQ==?=
    May 23, 2005
  4. Replies:
    0
    Views:
    561
  5. Replies:
    1
    Views:
    578
    David
    Apr 24, 2007
Loading...

Share This Page