Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Inheriting from System.Web.UI.Page and System.Web.UI.UserControl

Reply
Thread Tools

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

 
 
DanG
Guest
Posts: n/a
 
      01-24-2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      01-24-2006
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
>
>

 
Reply With Quote
 
 
 
 
Bruce Barker
Guest
Posts: n/a
 
      01-24-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
DanG
Guest
Posts: n/a
 
      01-24-2006
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.

 
Reply With Quote
 
DanG
Guest
Posts: n/a
 
      01-25-2006
Doh!

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

Thanks, guys
Dan

 
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
Inheriting dictionary attributes and manipulate them in subclasses Dominik Ruf Python 5 09-12-2009 03:03 PM
inheriting new and delete dragoncoder C++ 5 06-14-2007 11:19 AM
__new__ and dynamic inheriting Riccardo Galli Python 0 06-15-2005 09:57 AM
Inheriting operator() and templates Drew McCormack C++ 3 07-12-2004 02:25 PM
Creating / chaining exceptions and inheriting from their superclasses Mark Java 1 04-28-2004 02:49 PM



Advertisments