Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Access to the Title Element of an HTML Page

Access to the Title Element of an HTML Page

Scheduled Pinned Locked Moved ASP.NET
htmlhelpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Angel Reyes
    wrote on last edited by
    #1

    Is there any way of accessing the Title Element of an HTML Page from the code behind? I need a way of modifying the Text in the Title without having to go to each page on the site. Thanks for any help.

    S M 2 Replies Last reply
    0
    • A Angel Reyes

      Is there any way of accessing the Title Element of an HTML Page from the code behind? I need a way of modifying the Text in the Title without having to go to each page on the site. Thanks for any help.

      S Offline
      S Offline
      Stonie
      wrote on last edited by
      #2

      Use an inside your title tags and set its .Text property in your code behind. ;) Andrew Stone. http://andrewstone.net

      A 2 Replies Last reply
      0
      • S Stonie

        Use an inside your title tags and set its .Text property in your code behind. ;) Andrew Stone. http://andrewstone.net

        A Offline
        A Offline
        Angel Reyes
        wrote on last edited by
        #3

        I haven't tried it yet, but thanks for the tip. This is probably the first time anyone has answered one of my questions (not that I ask many). But again, thanks for your help.

        1 Reply Last reply
        0
        • S Stonie

          Use an inside your title tags and set its .Text property in your code behind. ;) Andrew Stone. http://andrewstone.net

          A Offline
          A Offline
          Angel Reyes
          wrote on last edited by
          #4

          I haven't tried it yet, but I don' think that this will work. The literal would have to be between the form tags in order to work correctly.

          J 1 Reply Last reply
          0
          • A Angel Reyes

            I haven't tried it yet, but I don' think that this will work. The literal would have to be between the form tags in order to work correctly.

            J Offline
            J Offline
            Jesse Squire
            wrote on last edited by
            #5

            Not at all. There is no requirement in ASP.NET for a server control to be within form tags to be accessible. If the control needs to participate in postback events, then it is required to be contained in the server form. For the record, I frequently use a Literal to set page titles, so the proposed solution should work for you. Hope that helps. :)   --Jesse

            1 Reply Last reply
            0
            • A Angel Reyes

              Is there any way of accessing the Title Element of an HTML Page from the code behind? I need a way of modifying the Text in the Title without having to go to each page on the site. Thanks for any help.

              M Offline
              M Offline
              Mariusz Wojcik
              wrote on last edited by
              #6

              You can also put <%= GetTitle() %> in the TITLE tag, and in your code create the function which returns page's title as string (C#):

              public string GetTitle()
              {
              return "MyPage. Access tick: " + DateTime.Now.Ticks;
              }

              Insted function you can use the property. -- Mariusz 'mAv' Wójcik master e-software engineer (BPC)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups