469,945 Members | 2,304 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

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 1087
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Matthew Roberts | last post: by
2 posts views Thread by Charles Law | last post: by
5 posts views Thread by Andrew Robinson | last post: by
4 posts views Thread by AalaarDB | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.