By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,659 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,659 IT Pros & Developers. It's quick & easy.

Inherit from a UserControl

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

Thanks,
Joe
Sep 9 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#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/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "Joe" <jb*******@noemail.noemail>
Subject: Inherit from a UserControl
Date: Tue, 9 Sep 2008 15:43:13 -0400
Lines: 7

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

Thanks,
Joe
Sep 10 '08 #2

P: n/a
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Joe" <jb*******@noemail.noemail>
Subject: Inherit from a UserControl
Date: Tue, 9 Sep 2008 15:43:13 -0400
>
Is it possible to inherit from a UserControl? If I try my user control
class is not recognized.

Thanks,
Joe
Sep 17 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.