Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Inheriting from Custom Control

Reply
Thread Tools

Inheriting from Custom Control

 
 
luminousc@yahoo.com
Guest
Posts: n/a
 
      08-17-2005
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

 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      08-17-2005
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.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating custom gridview (inheriting from gridview class) =?Utf-8?B?V2ViTWF0cml4?= ASP .Net 1 10-21-2006 11:56 PM
Inheriting Custom Control Damien ASP .Net Building Controls 1 07-15-2005 03:14 PM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net 1 04-05-2005 01:39 PM
Custom Control inheriting from DataGrid - SortCommand, PageIndexChanged not working Ole ASP .Net Building Controls 0 02-10-2004 12:48 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments