2

Is there any way to create a handler that changes the head tag content real time?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
BorisD
  • 2,231
  • 5
  • 25
  • 35
  • Probably your question is too broad. I could imagine writing a handler for the asp.net pipe. But on the other hand using a master page would be easier... – Uwe Keim Dec 24 '12 at 15:39
  • Yes, I saw some examples of handlers with master page...but unfortunately in project there is no master page & it is web app. – BorisD Dec 24 '12 at 15:42
  • 1
    I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Dec 24 '12 at 16:46

2 Answers2

5

You can use HtmlGenericControl Server Control for this purpose.

HtmlGenericControl Server Control Creates a server-side control that maps to an HTML element not represented by a specific .NET Framework class, such as <body> and <div>.

Try Below one.

var h1 = new HtmlGenericControl("h1");
h1.InnerHtml = "Your header content";

For more information check HtmlGenericControl Server Control Declarative Syntax

I hope this will help to you.

Sampath
  • 63,341
  • 64
  • 307
  • 441
1

You can create a custom HTTP Module:

http://msdn.microsoft.com/en-us/library/ms227673.aspx

Here's an example of how to add a script to the head of each page:

How2: what event to hook in HttpModule for putting js links into head element

Community
  • 1
  • 1
Nick Bray
  • 1,953
  • 12
  • 18