Base Page Headers

P

Patxi

I repost this due to a mismatxh with Subject...

Hi,

I've created a class inheriting System.Web.UI.Page, and all this stuff I
was doing worked until now...

I want to setup some 'global' meta values, doing this:

I tested in my class contructor...

HtmlLink link = new HtmlLink();
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("href", "~/newstyle.css");
this.Header.Controls.Add(link);

I have this error on an aspx.cs inheriting my class instead of
System.Web.UI.Page:

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:

Line 176: link.Attributes.Add("href", "~/newstyle.css");
Line 177: this.Page.Header.Controls.Add(link);

It would be really nice if I could render all meta stuff in my base
class without calling it from page.aspx.cs...

P.S.: if i put the code in Page_Load method of my base class, nothing
happens...

TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,274
Latest member
JessMcMast

Latest Threads

Top