473,396 Members | 2,030 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,396 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 2362
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.