473,810 Members | 3,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.W ebControls.Tabl e wizardBaseTable ;
public class BaseWizard : System.Web.UI.U serControl
{
public Hashtable WizardEventLog = new Hashtable();
}

and:

public class wizard_Request : DTS_UI.Componen ts.Wizards.Base Wizard
{
WizardEventLog. Add(DateTime.No w.ToLongTimeStr ing() + " 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 1178
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.C ontrol, 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*******@yaho o.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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.W ebControls.Tabl e wizardBaseTable ;
public class BaseWizard : System.Web.UI.U serControl
{
public Hashtable WizardEventLog = new Hashtable();
}

and:

public class wizard_Request : DTS_UI.Componen ts.Wizards.Base Wizard
{
WizardEventLog. Add(DateTime.No w.ToLongTimeStr ing() + " 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
2671
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 inherit from my new SecurePage class and not the old Page class, the designer breaks and will only allow me into html mode. Bugger. The error message given is:
0
1764
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 class, it takes 3 lines of code. Example: Dim TextBox as System.Web.UI.WebControls.TextBox 1..TextBox = New System.Web.UI.WebControls.TextBox
8
1960
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 and CSS, and powered by ASP.NET. My first problem, which I'm near to solving, was that ASP.NET doesn't produce valid XHTML output. We don't want to spend money on third-party components, and we can't wait for ASP.NET 2.0, so we needed to find a
1
336
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 down and look at it, I'm wondering why it behaves the way it does, and also how to improve its functionality. First, understand the basic format of a type-safe collection:
2
1815
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 this is the right approach (please tell me if it is not), how then do I make it so that the group box cannot be moved around on my set of controls, but is also able to act as container for other controls? If I leave the modifier of the group box...
1
11721
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 RowCreated and Sorting events to add certain effects. For example inserting sorting direction image to the column header. I want to create one custom grid view that implement all this logic to be reused through out this app, so I wont need to copy...
5
3011
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 list that corresponds with the number of pages, but I am unable to wire up the Selected Index Changed event. Auto PostBack is set to true and the page is posting back when the DDL is selected / chaged, but the event is never being called. Any...
3
1319
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 them fine at design time. I'll give a short example: public class baseA: UserControl
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
10644
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
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...
1
10393
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
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...
0
6882
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
5550
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
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
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.