473,322 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Inheriting from System.Web.UI.Page and System.Web.UI.UserControl

Howdy,

On past .NET projects, I only had System.Web.UI.Page forms. One
application needed a set of functions to do processing against the
Page, Session and Request objects associated with the current Form. I
handled this by making a new class (BasePage) which inherits from
System.Web.UI.Page. Each form would then inherit from BasePage rather
than System.Web.UI.Page.

I am now on a project that has both System.Web.UI.Page and
System.Web.UI.UserControl forms. I want to do the same type of
BasePage processing for the UserControl screens, but I can't inherit
them from BasePage. Currently, I made two classes that are identical,
except that each inherit from the respective System.Web.UI object.
Obviously, I would like a single class that would handle both types of
forms, but I can't figure out the proper way to do it. I could use a
clue.

Thanks
Dan

Jan 24 '06 #1
4 6708
UserControl is not page. So you cannot inherit your usercontrols from your
BasePage. In my understanding, what you want is to use functions in your
BasePage from those usercontrols. One way you can do is to cast use
usercontrol's contaniner page to BasePage. The use its functions:

BasePage parentPage = (BasePage)this.Page; // C#

Or

Dim parentPage As BasePage = CType(Me.Page, BasePage) ' VB.NET
HTH

Elton Wang
"DanG" wrote:
Howdy,

On past .NET projects, I only had System.Web.UI.Page forms. One
application needed a set of functions to do processing against the
Page, Session and Request objects associated with the current Form. I
handled this by making a new class (BasePage) which inherits from
System.Web.UI.Page. Each form would then inherit from BasePage rather
than System.Web.UI.Page.

I am now on a project that has both System.Web.UI.Page and
System.Web.UI.UserControl forms. I want to do the same type of
BasePage processing for the UserControl screens, but I can't inherit
them from BasePage. Currently, I made two classes that are identical,
except that each inherit from the respective System.Web.UI object.
Obviously, I would like a single class that would handle both types of
forms, but I can't figure out the proper way to do it. I could use a
clue.

Thanks
Dan

Jan 24 '06 #2
this would be multi-inheritance, which c# (and the clr) do not support. the
best you can do is create a common interface that both expose. the internal
routines should call common code.

-- bruce (sqlwork.com)
"DanG" <da**@rmci.net> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Howdy,

On past .NET projects, I only had System.Web.UI.Page forms. One
application needed a set of functions to do processing against the
Page, Session and Request objects associated with the current Form. I
handled this by making a new class (BasePage) which inherits from
System.Web.UI.Page. Each form would then inherit from BasePage rather
than System.Web.UI.Page.

I am now on a project that has both System.Web.UI.Page and
System.Web.UI.UserControl forms. I want to do the same type of
BasePage processing for the UserControl screens, but I can't inherit
them from BasePage. Currently, I made two classes that are identical,
except that each inherit from the respective System.Web.UI object.
Obviously, I would like a single class that would handle both types of
forms, but I can't figure out the proper way to do it. I could use a
clue.

Thanks
Dan

Jan 24 '06 #3
I was thinking ... (uh-oh)

The UserControls are on a form which inherits from System.Web.UI.Page.
Can I change that form to use BasePage, and then reference its
functions from the UserControl forms?

Using some of Elton's code, I tried adding
Dim parentPage As BasePage = CType(Me.Page, BasePage)
and then attempted to reference parentPage.<BasePage function>, but it
didn't work.

Jan 24 '06 #4
Doh!

I had the old BasePage functions still set to Protected. Had to make
them Public.

Thanks, guys
Dan

Jan 25 '06 #5

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

Similar topics

1
by: Jo Yoshida | last post by:
http://groups.google.com/groups?hl=en&lr=&threadm=F9A88B8F-6DDD-405C-9559-B2379ABE8CA7%40microsoft.com&rnum=1&prev=/groups%3Fq%3DSystem.MissingFieldException:%2BField%2Bnot%2Bfound%26hl%3Den%26lr%3D%2...
4
by: Alan Silver | last post by:
Hello, I am displaying product details on a page and am allowing the site owner to specify the style in which the product details are displayed. I am debating which of two approaches to use here...
2
by: Charles Law | last post by:
I have a base class - ComponentBase - that inherits from UserControl. My class implements IComponentBase, which defines a minimal set of core properties and methods. All my other components inherit...
4
by: elziko | last post by:
I would like to do the following: Create a class that inherits from a usercontrol. Then add a control to the designer Call this new class ClassA. Many controls I need will start off like this...
3
by: YYZ | last post by:
I swear I've done my research, and now I was just hoping someone could explain this to me. I've got a base class (usercontrol) that I am using just as an interface. Meaning, I've defined...
9
by: Dominique | last post by:
I'm trying to create a C# composite control and have inherited from UserControl. This new control contains 9 buttons with images on them ( no text ). Firstly, what is the best way to expose...
5
by: UJ | last post by:
I have a user control that inherits from the standard windows text box. I have a routine that adds stuff to it. I have compiled it into a dll. I have added it to my app and I can debug into it. I...
1
by: Sue | last post by:
Web app: asp.net 2003, IE, IIS, VB top: system.page -first level: placeholder --second level: usercontrol ---third level: user control containing a datagrid Datagrid itemdatabound assigns:...
1
by: =?Utf-8?B?a2Fu?= | last post by:
hi, Consider i have built a UserControl say 'ColorMixer' in proj 'Step1'(Windows Control Proj). Now when create another proj 'Step2' as Windows Control and try adding 'ColorMixer' as inherited...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.