access <HEAD> from codebehind
ASP.NET
2
Posts
2
Posters
0
Views
1
Watching
-
Hi. Is it possible to access and add a line to the htmlheader tag from the codebehind?
-
Hi. Is it possible to access and add a line to the htmlheader tag from the codebehind?
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