Document title

Discussion in 'ASP .Net' started by Tumurbaatar S., Aug 24, 2005.

  1. How to change a document's title programmatically, from the Page_Load() for
    example?
    Tumurbaatar S., Aug 24, 2005
    #1
    1. Advertising

  2. you can either create a literal and set its text to:
    <Title>Some TITLE</title>

    Or, you can declare a public variable in your code like follows
    public string PageTitle;

    then in your Title tag do this:
    <TITLE><%=PageTitle%></TITLE>

    "Tumurbaatar S." <> wrote in message
    news:...
    > How to change a document's title programmatically, from the Page_Load()
    > for example?
    >
    Grant Merwitz, Aug 24, 2005
    #2
    1. Advertising

  3. Thank you!
    There's no a special property/method to manipulate with a document title?
    So, only way is to combine ASP.NET script and HTML tags.
    I think that <%= PageTitle %> will assign initial value of the variable,
    i.e. before
    processing it within Page_Load(). May be it will work as I think:

    <TITLE><%# PageTitle %></TITLE>
    public string PageTitle;
    Page_Load()
    {
    PageTitle = some_expression;
    DataBind();
    }

    Am I right?


    "Grant Merwitz" <> wrote in message
    news:...
    > you can either create a literal and set its text to:
    > <Title>Some TITLE</title>
    >
    > Or, you can declare a public variable in your code like follows
    > public string PageTitle;
    >
    > then in your Title tag do this:
    > <TITLE><%=PageTitle%></TITLE>
    >
    > "Tumurbaatar S." <> wrote in message
    > news:...
    >> How to change a document's title programmatically, from the Page_Load()
    >> for example?
    >>

    >
    >
    Tumurbaatar S., Aug 24, 2005
    #3
  4. Sounds fine to me, never tested i though.

    if you change the # to and =, you wouldn't have to use the Page.DataBind()
    method.
    But it should work fine

    "Tumurbaatar S." <> wrote in message
    news:...
    > Thank you!
    > There's no a special property/method to manipulate with a document title?
    > So, only way is to combine ASP.NET script and HTML tags.
    > I think that <%= PageTitle %> will assign initial value of the variable,
    > i.e. before
    > processing it within Page_Load(). May be it will work as I think:
    >
    > <TITLE><%# PageTitle %></TITLE>
    > public string PageTitle;
    > Page_Load()
    > {
    > PageTitle = some_expression;
    > DataBind();
    > }
    >
    > Am I right?
    >
    >
    > "Grant Merwitz" <> wrote in message
    > news:...
    >> you can either create a literal and set its text to:
    >> <Title>Some TITLE</title>
    >>
    >> Or, you can declare a public variable in your code like follows
    >> public string PageTitle;
    >>
    >> then in your Title tag do this:
    >> <TITLE><%=PageTitle%></TITLE>
    >>
    >> "Tumurbaatar S." <> wrote in message
    >> news:...
    >>> How to change a document's title programmatically, from the Page_Load()
    >>> for example?
    >>>

    >>
    >>

    >
    >
    Grant Merwitz, Aug 24, 2005
    #4
  5. Tumurbaatar S.

    Siva M Guest

    Another option:

    ....
    <head>
    <title id="pageTitle" runat=server></title>
    </head>
    ....

    In the code-behind:

    pageTitle.InnerText = "Your page title goes here...";


    "Tumurbaatar S." <> wrote in message
    news:...
    How to change a document's title programmatically, from the Page_Load() for
    example?
    Siva M, Aug 24, 2005
    #5
  6. i was also thinking that.

    But how do you declare the title in your code behind?
    Vis studio doesn't add it automatically

    "Siva M" <> wrote in message
    news:uDYV%...
    > Another option:
    >
    > ...
    > <head>
    > <title id="pageTitle" runat=server></title>
    > </head>
    > ...
    >
    > In the code-behind:
    >
    > pageTitle.InnerText = "Your page title goes here...";
    >
    >
    > "Tumurbaatar S." <> wrote in message
    > news:...
    > How to change a document's title programmatically, from the Page_Load()
    > for
    > example?
    >
    >
    >
    Grant Merwitz, Aug 24, 2005
    #6
  7. Tumurbaatar S.

    Siva M Guest

    Hi,

    Declare it as HtmlGenericControl.


    "Grant Merwitz" <> wrote in message
    news:...
    i was also thinking that.

    But how do you declare the title in your code behind?
    Vis studio doesn't add it automatically

    "Siva M" <> wrote in message
    news:uDYV%...
    > Another option:
    >
    > ...
    > <head>
    > <title id="pageTitle" runat=server></title>
    > </head>
    > ...
    >
    > In the code-behind:
    >
    > pageTitle.InnerText = "Your page title goes here...";
    >
    >
    > "Tumurbaatar S." <> wrote in message
    > news:...
    > How to change a document's title programmatically, from the Page_Load()
    > for
    > example?
    >
    >
    >
    Siva M, Aug 24, 2005
    #7
    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:
    445
    Steve C. Orr, MCSD
    Aug 10, 2003
  2. Replies:
    0
    Views:
    512
  3. Replies:
    1
    Views:
    531
    David
    Apr 24, 2007
  4. soonic
    Replies:
    11
    Views:
    1,767
    soonic
    Jul 27, 2011
  5. Russell
    Replies:
    2
    Views:
    275
    Russell
    Sep 13, 2004
Loading...

Share This Page