Inherit from a UserControl

J

Joe

Is it possible to inherit from a UserControl? If I try my user control
class is not recognized.

Thanks,
Joe
 
S

Steven Cheng [MSFT]

Hi Joe,

As for "inheriting Usercontrol", do you mean you want to create a custom
class which derive from the ascx user control's codebehind class?

If this is the case, the problem is that ASP.NET aspx page or usercontrol
class are partial class, they're still not completely determined at
design-time. When page/usercontrol is requested at runtime, a new dynamic
class will be generated and compiled.

#Understanding Page Inheritance in ASP.NET 2.0
http://www.west-wind.com/WebLog/posts/3016.aspx

So far, if you want to define a commone user control class and reuse it
later via inherittance, you can consider the following means:

* define a dedicated base usercontrol class(inherit from Usercontrol) and
make your another ascx usercontrol inherit from that one.
* Also, you need to define most of the common properties and methods in the
base class

A similar web article apply this approach on page:

http://aspnet.4guysfromrolla.com/articles/041305-1.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
 
S

Steven Cheng [MSFT]

Hi Joe,

How are you doing?

Have you got any progress on this or still have any questions?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
From: (e-mail address removed) (Steven Cheng [MSFT])
Organization: Microsoft
Date: Wed, 10 Sep 2008 03:29:25 GMT
Subject: RE: Inherit from a UserControl
 
S

Steven Cheng

Hi Joe,

Have you got any progress on this issue or does the information in my last
reply help some?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top