Changing the document.title from a user control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    #1

    Changing the document.title from a user control

    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 programmaticall y
    using VB.NET in ASP.NET from a User Control? Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • Cor Ligthert

    #2
    Re: Changing the document.title from a user control

    Nathan,

    Not the nicest stuff, although I am busy again at the moment with it.
    (Don't set imports to this namespace).

    http://msdn.microsoft.com/library/de.../reference.asp

    It follows completly the DOM

    I hope this helps,

    Cor


    Comment

    • Ken Tucker [MVP]

      #3
      RE: Changing the document.title from a user control

      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 htmlgenericcont rol

      To change the page title from the page

      PageTitle.Inner Text= "My new page title"

      To access this from a user control

      Dim pagetitle as htmlgenericcont rol

      Try
      pagetitle=ctype (me.page.findco ntrol("PageTitl e"), htmlgenericcont rol)
      pagetitle.inner text="Live from user control"
      catch
      end try

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

      "Nathan Sokalski" wrote:
      [color=blue]
      > 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 programmaticall y
      > using VB.NET in ASP.NET from a User Control? Thanks.
      > --
      > Nathan Sokalski
      > njsokalski@hotm ail.com
      > http://www.nathansokalski.com/
      >
      >
      >[/color]

      Comment

      Working...