473,811 Members | 2,982 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheriting a Base class in a web form

Hi guys/gals,

I'm using VS.net 2003 and having trouble with the following:

I am trying to inherit a base class into a web form, but VS will then not
allow me to add any ASP.NET controls using the designer. The base class does
derive from System.Web.UI.P age.

Here's a code snippet:

public class BaseAdminPage : System.Web.UI.P age

{}

public class ContactAdmin : BaseAdminPage

{

private void Page_Load(objec t sender, System.EventArg s e)

{

// Put user code to initialize the page here

}

#region Web Form Designer generated code

override protected void OnInit(EventArg s e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeCompo nent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeCompo nent()

{

this.Load += new System.EventHan dler(this.Page_ Load);

}

#endregion

}

Can anyone help?

Thanks,

Peter
Nov 16 '05 #1
3 3371
From http://www.asptoday.com/Content.aspx?id=1972

In any application, it is desirable for the interface to be consistent. In
web applications specifically, you want the user to feel that they are on
the same website as they move from page to page, having the same navigation,
color scheme, and layout on every page. In .NET Windows Forms, it is
possible to use visual inheritance to have the look and composition of one
form, inherit from another. Since each form is itself a class, it would make
sense that forms can inherit from each other. However, this capability is
not innate to ASP.NET Web Forms. While inheritance is supported, this is
limited to code inheritance. Methods and Properties can be inherited,
however one .aspx page cannot inherit the server controls, form elements,
images and HTML script from another base .aspx page.

--

HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"Peter Cresswell" <p-*********@iname .com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi guys/gals,

I'm using VS.net 2003 and having trouble with the following:

I am trying to inherit a base class into a web form, but VS will then not
allow me to add any ASP.NET controls using the designer. The base class
does derive from System.Web.UI.P age.

Here's a code snippet:

public class BaseAdminPage : System.Web.UI.P age

{}

public class ContactAdmin : BaseAdminPage

{

private void Page_Load(objec t sender, System.EventArg s e)

{

// Put user code to initialize the page here

}

#region Web Form Designer generated code

override protected void OnInit(EventArg s e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeCompo nent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeCompo nent()

{

this.Load += new System.EventHan dler(this.Page_ Load);

}

#endregion

}

Can anyone help?

Thanks,

Peter

Nov 16 '05 #2
It's a limitation of the VS.NET designer. Many other extremely annoying
quirks are fixed in
VS.NET 2005 - and this is one of them.

Note that it's not entirely impossible to use asp.net inheritance with
visual studio, just extremely frustrating.

You'll need to do one of these:
1. use #if debug statements to "comment out" the inheritance during design
time. Yuck.
2. not use the vs.net designer (this is what I do)
3. wait for vs.net 2005
4. not use inheritance.

If you're trying for a common template, try using Paul Wilson's master pages
http://authors.aspalliance.com/PaulW...rticles/?id=14

--
-Philip Rieck
http://philiprieck.com/blog/

-
"Peter Cresswell" <p-*********@iname .com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hi guys/gals,

I'm using VS.net 2003 and having trouble with the following:

I am trying to inherit a base class into a web form, but VS will then not
allow me to add any ASP.NET controls using the designer. The base class
does derive from System.Web.UI.P age.

Here's a code snippet:

public class BaseAdminPage : System.Web.UI.P age

{}

public class ContactAdmin : BaseAdminPage

{

private void Page_Load(objec t sender, System.EventArg s e)

{

// Put user code to initialize the page here

}

#region Web Form Designer generated code

override protected void OnInit(EventArg s e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeCompo nent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeCompo nent()

{

this.Load += new System.EventHan dler(this.Page_ Load);

}

#endregion

}

Can anyone help?

Thanks,

Peter

Nov 16 '05 #3
Thanks Philip.

I'm only just starting out with asp.net programming. You mentioned that
you do not use the VS.NET designer, can you recommend an alternative
that I could look at?

Peter

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4

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

Similar topics

15
1716
by: JustSomeGuy | last post by:
this doesn't want to compile.... class image : public std::list<element> { element getElement(key k) const { image::iterator iter; for (iter=begin(); iter != end(); ++iter) { element &elem(*iter);
29
5908
by: shaun roe | last post by:
I want something which is very like a bitset<64> but with a couple of extra functions: set/get the two 32 bit words, and conversion to unsigned long long. I can do this easily by inheriting from bitset<64>, but I know that STL has no virtual destructor. Can I get around this by calling the baseclass destructor explicitly in my derived class? Is there another way to get all of the bitset<64> functionality without rewriting a lot of...
11
2170
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain methods, such as public void Add(MyClass c). How can I enforce the same behavior (of requiring to implement a member with a new return type in an inherited class) in the master class (similar to the CollectionBase)? I have a class called...
2
1858
by: Simon | last post by:
Hi, Just to get started.... I've created a very simple web form, "Simple", using VS and I dropped a HTML img control on the design view. I referenced a picture and it is displayed in browser view. Very simple. I have created a second form and in the code-behind page I have altered the class definition to inherit from, "Simple".
4
1200
by: elziko | last post by:
I would like to do the following: Create a class that inherits from a usercontrol. Then add a control to the designer Call this new class ClassA. Many controls I need will start off like this so I'd like to create all controls form now on from this base control. So, for example, I inherit from this base control and add the further controls required to form this part of my UI. Call this ClassB
3
2378
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes get MyVarialble is not declared errors when the variable is quite clearly declared, when I change it to public and then back again to private the error goes away!!! Also I get lots of member not found errors, these however don't stop me from...
7
4968
by: Vish | last post by:
Hi, I have a base form from which i want all of my forms to inherit from. The base form has three buttons anchored to the bottom right of the base form. When i first inherit a new form from the base form everything seems to be fine. The 3 buttons from the base form show up on the bottom right of the inherited form. But as i started adding new controls and building it i found that the 3 buttons from the base form disappeared. When i...
1
1595
by: BillE | last post by:
Can I inherit from a web form? I would like to reuse procedures in a web form base class code behind by inheriting from it. For example, I would like to have a HandleError function defined in the base class code behind, which would then be available to any web forms code behind which inherited the base web form code behind. Is this supported? I can't find a way to do it.
4
1701
by: AalaarDB | last post by:
struct base { int x, y, z; base() {x = 0; y = 0; z = 0;}; base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;}; }; struct intermediate1 : public virtual base {}; struct intermediate2 : public virtual base
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10395
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10137
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7674
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5564
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.