BorisD
BorisD

Reputation: 2261

Create Handler that manipulates head tag

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

Upvotes: 2

Views: 164

Answers (2)

Nick Bray
Nick Bray

Reputation: 1963

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

Upvotes: 1

Sampath
Sampath

Reputation: 65860

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.

Upvotes: 5

Related Questions