473,498 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Controls and Inheritance

I have a user control that is basically a Datagrid with a few
additional controls for filtering the data and showing/hiding columns.
I'd like to be able to reuse this control in different places
throughout my code but allow it to work with different tables in the
database.

I thought that I would use the Template pattern to achieve this. I put
all the functions in an abstract base class which inherited from
UserControl except a BindDataGrid() function which I left for the
derived classes to override depending on the table they want to
display in the datagrid. Everything compiled fine but I can't get the
thing to run. The InitialComponent() function keeps erroring out when
it tries to attach the event functions in the base class because the
controls are null.

I must admit that I don't understand how those variables are set in
normal ASPX pages but it must be in the code that is generated behind
the scenes.

I also don't understand how the .aspx pages should be related. When I
actually want to create another control that inherits from the base
user control, obviously the code behind of the derived control will
inherit from the codebehind of the base control, but what about the
..aspx page itself? Do I leave it blank and make it inherit from the
base control's .aspx page? I'm kinda foggy on that.

It looks like some people have tried this before but I haven't seen
anyone definitively say that this does or doesn't work. I think could
probably achieve the effect I'm looking for using the Strategy pattern
instead of the Template pattern, but I'm just curious as to why this
isn't working.

Thanks,
Dave
Nov 18 '05 #1
0 1081

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

Similar topics

2
2594
by: Rachel Suddeth | last post by:
Here is my scenario: I have a few custom controls that I set up on a form and tested setting properties and appearances. Then I added a couple references to the project which add classes I need to...
1
1005
by: Vannela | last post by:
I want to create some 100 user controls and write the common methods for all these user controls ,is this possible? Also i want to refer this user control and their methods on the aspx.cs file...
5
1946
by: jqpdev | last post by:
Hello all... I'm coming from a Borland Delphi background. Delphi has a specific component called a Data Module. In the designer the Data Module behaves like a windows form. A developer can...
1
6248
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
7
3176
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
9
4066
by: Alan Silver | last post by:
Hello, I have a user control which I am trying to load dynamically, but am running into problems. I think the problem is because I have two .ascx files that refer to the same .ascx.cs file. A...
4
1093
by: sonic | last post by:
Hello, I am trying to create a custom control hierarchy that encapsulates web controls in my framework and run into a interesting problem. my framework will automatically save all user control...
8
3154
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
8
1682
by: | last post by:
I'm looking for some design guidance on a collection of projects I'm working on. The project involves a bunch of websites constructed out of a collection of user controls. Different user...
2
5472
by: wildThought | last post by:
I have a window with a user control on it. I want to be able to swap out different user controls depending on a menu choice. The swappable user controls UserControlBaseA and UserControlBaseB are...
0
7125
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
7004
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...
0
7167
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
7208
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
7379
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...
0
3095
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
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...

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.