473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Base Page

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...

TIA
May 12 '06 #1
2 2361
Try putting it in the base page's Page_Load event.
"Patxi" <pa***@yahoo.com> wrote in message
news:44**********************@news.free.fr...
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...

TIA

May 12 '06 #2
If I put it in Page_Load(), I have no errors, but I assume that's
beacause code inside Page_Load() is not called, the meta tags aren't
rendered...

Michael Bosch wrote:
Try putting it in the base page's Page_Load event.
"Patxi" <pa***@yahoo.com> wrote in message
news:44**********************@news.free.fr...
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...

TIA


May 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: z. f. | last post by:
Hi, i have a class that is derived from System.Web.UI.Page, and this is the class i use in my application as PageBase. all other page classes are deriverd from my PageBase instead of the...
3
by: Mikip | last post by:
Hi, I have some properties that are common to all pages so I have created a base class which every page inherits from. I now also want to use these properties within User Controls on the page....
1
by: Craig Street | last post by:
Hi How do i create a base page in ASP.NET 2.0? I don't want to use master pages as I don't need any visual inheritance. You could do this simply in ASP.NET 1.1 by creating a base page that...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
2
by: craig.wagner | last post by:
I have converted two ASP.NET 1.1 applications to ASP.NET 2.0. Each one had some odd results, most of which I've been able to address. I'm looking for some confirmation/advice. Both applications...
3
by: Jeff User | last post by:
Hello I am using C#, .net1.1 Vis Studio 2003 I am using homeBase.aspx.cs page as a base for several other aspx/aspx.cs web pages. The base page handles some operations that are common to all...
2
by: Wade | last post by:
Hi all, We have created some "Base" class pages for our WebForms and UserControls. For instance, when we create a WebForm called "WebForm1.aspx", instead of inheriting from "System.Web.UI.Page"...
3
by: Goran Djuranovic | last post by:
Hi all, Is there a way to retrieve a derived class name inside a subroutine or a function of the base class? I am trying to get some data from the database, based on which derived class is calling...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
3
by: =?Utf-8?B?c29uaWNt?= | last post by:
Hi, What is the best way of populating a repeater control from a SQL Database using a base class. I am trying to impliment a base class that can be used across future websites and will populate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.