473,394 Members | 2,090 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.

Inheriting from Custom Control

Hi guys,

I'm still a relative newbie at oop, as my background has been in old
fashioned vanilla ASP, so please try to make your responses as simple
as possible.

I'm having issues with inheritence in my c#.net app. I've built a basic
web control with some members and properties. I'm now trying to create
a more specific class that uses all the base properties and then adds
some more for a specific purpose. I can't seem to find the right syntax
to get this to work.

simplified Example:

public System.Web.UI.WebControls.Table wizardBaseTable;
public class BaseWizard : System.Web.UI.UserControl
{
public Hashtable WizardEventLog = new Hashtable();
}

and:

public class wizard_Request : DTS_UI.Components.Wizards.BaseWizard
{
WizardEventLog.Add(DateTime.Now.ToLongTimeString() + " Wizard
Initialised","<status at init here>");
string aString = wizardBaseTable.ID.ToString();
}

Basically, the WizardEventLog.Add() line executes fine and I can see
the entry added successfully, but when it get's to referencing the
wizardBaseTable, the app crashes with a null reference error even
though the Table is initialised ok in the markup file of the base
control version.

I'm guessing that maybe I have to use something like the LoadControl()
method when defining the inheritence but I can't find anything that I
understand on Google / GoogleGroups

Thanks

C Poole

Nov 19 '05 #1
1 1166
Save yourself a lot of headaches, and don't try to use inheritance with
UserControls (at least right away). Create a Custom Control that inherits
System.Web.UI.Control, and go from there. Here is a link to the online .Net
SDK section on creating custom Controls for ASP.Net:

http://msdn.microsoft.com/library/en...asp?frame=true

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.

<lu*******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi guys,

I'm still a relative newbie at oop, as my background has been in old
fashioned vanilla ASP, so please try to make your responses as simple
as possible.

I'm having issues with inheritence in my c#.net app. I've built a basic
web control with some members and properties. I'm now trying to create
a more specific class that uses all the base properties and then adds
some more for a specific purpose. I can't seem to find the right syntax
to get this to work.

simplified Example:

public System.Web.UI.WebControls.Table wizardBaseTable;
public class BaseWizard : System.Web.UI.UserControl
{
public Hashtable WizardEventLog = new Hashtable();
}

and:

public class wizard_Request : DTS_UI.Components.Wizards.BaseWizard
{
WizardEventLog.Add(DateTime.Now.ToLongTimeString() + " Wizard
Initialised","<status at init here>");
string aString = wizardBaseTable.ID.ToString();
}

Basically, the WizardEventLog.Add() line executes fine and I can see
the entry added successfully, but when it get's to referencing the
wizardBaseTable, the app crashes with a null reference error even
though the Table is initialised ok in the markup file of the base
control version.

I'm guessing that maybe I have to use something like the LoadControl()
method when defining the inheritence but I can't find anything that I
understand on Google / GoogleGroups

Thanks

C Poole

Nov 19 '05 #2

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

Similar topics

3
by: thechaosengine | last post by:
Hi all, I wanted to put some common security functions into a class that inherits from the Page class and then use the new class as the basis for all my pages. Unfortunately, if I try and...
0
by: Harry F. Harrison | last post by:
Here's the situation...Context - Using an Inherited WebControl object as a base for server custom controls. In a web custom control, whenever I create a child control and add it to the Controls...
8
by: Anthony Williams | last post by:
Morning all, I'm having a wee problem with a project I'm working on at the moment. I'm leading my company into producing a website, based upon Web Standards, which will be created using XHTML...
1
by: Matthew Roberts | last post by:
Howdy Everyone, I am having trouble understanding the process of creating a type-safe collection by inheriting from the CollectionBase class. I have done it plenty of times, but now that I sit...
2
by: Charles Law | last post by:
I want a set of controls that all have a border, like a group box. I thought I would create a base control containing just a group box from which my set of controls could inherit. Assuming that...
1
by: WebMatrix | last post by:
Hi, I started a new web application which so far has several grdiviews displaying data. I find myself reimplementing the same logic (copy/pasting really) in grid's event ItemDataBound and...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
3
by: Cyr1dian | last post by:
Hi, My problem is that a custom control "newA" that inherits from a base custom control "baseA" is not displaying any contained controls - that were not inherited - at run time, but displays...
4
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 :...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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,...
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.