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 <HEAD> from codebehind

access <HEAD> from codebehind

Scheduled Pinned Locked Moved ASP.NET
question
2 Posts 2 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.
  • T Offline
    T Offline
    troels_sorensen
    wrote on last edited by
    #1

    Hi. Is it possible to access and add a line to the htmlheader tag from the codebehind?

    A 1 Reply Last reply
    0
    • T troels_sorensen

      Hi. Is it possible to access and add a line to the htmlheader tag from the codebehind?

      A Offline
      A Offline
      Andrew Quinn AUS
      wrote on last edited by
      #2

      Hi, Is it HTML tags you want to right there? or comments? You can make <head> a server-side control and add items to it from there, e.g.

      <head runat='server' id='htmlHeader'>
      ...
      ...
      ...
      <'/head>

      Then in your code-behind...

      public class WebForm1 : System.Web.UI.Page
      {
      	protected System.Web.UI.HtmlControls.HtmlContainerControl htmlHeader;
      
      	private void Page\_Load(object sender, System.EventArgs e)
      	{
      		HtmlGenericControl htmlMeta1 = new HtmlGenericControl("meta");
      		htmlMeta1.Attributes\["name"\] = "My example";
      		htmlHeader.Controls.Add(htmlMeta1);
      		// ...
      	}
      }
      

      If it's comments, you could use the above with the <comment> element but this is a Microsoft extension to HTML3.2 so may not be supported by other browsers (this may or may not be an issue as the browser will most likely not render the contents anyway) Hope this helps, Andy

      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