473,563 Members | 2,831 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 InitialComponen t() 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 1087

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

Similar topics

2
2601
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 get data from the server to actually do something useful. (These are generated by 3rd party database software.) After adding those references,...
1
1007
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 is it possible (after placing this user control on the web form )? Please give me few code snippets of user controls which satisfy my problem
5
1950
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 drop non-visual (controls) on the data module surface and wire them up and create procedures, functions, event procedures. In the source file (code...
1
6263
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 variable (targetId) in to the usercontrol (IntergySite.aspx) by calling its setter method. Currently, I am using if-then-else and hardcoded the User...
7
3182
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 -- UC/ ----- Classic/
9
4081
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 simple example is like this... Ferret1.ascx =========
4
1096
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 values/preferences and initiate them from query string. My framework will provide all necessary work and all the developers will have to do is:...
8
3165
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 I'm having is that the partial class signature in my projectDetails.ascx.cs file looks like this: public partial class...
8
1690
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 populations with different access rights and "roles" will be visiting the site. I will be using ASP.NET 2.0's membership, roles, and profiles stuff to...
2
5483
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 inherited from UserControlBase. What I did is I placed UserControlBase on my window and it has a name of uc1. Now when the window loads or if the...
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7638
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...
0
7948
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...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
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...

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.