|
-
March 15th, 2004, 01:37 PM
#1
Creating/using a new base class UserControl
I have a large project I've been asked to contribute to at work, which utilizes a number of System.Web.UI.UserControl files. Most of these files duplicate about 90% of their code, so I am trying to consolidate and reuse a bit. My solution was to provide another layer of class abstraction, such that:
Code:
Public MustInherit Class MyBaseControl
Inherits System.UI.Web.UserControl
...
Public Class MyControl
Inherits MyBaseControl
MyBaseControl declares most all the code that is used, with only one control-specific function left in MyControl (actually, it's declared MustOverride in MyBaseControl).
Everything compiles and runs fine at run-time. The problem occurs in design-time: When I try to open MyControl in the [VS.NET 2003] designer, the IDE chokes and complains about the .ascx not being a valid file.
After doing some poking around, it appears the problem is that the designer is looking for certain interface methods from the class - which MyControl doesn't have because I haven't propogated them up from System.UI.Web.UserControl. But I'm having trouble figuring out which methods I need to implement.
If somebody could point me in the right direction (a tutorial that shows how to do this (create and consume a new UserControl base class), for example) I'd really appreciate it.
Thanks,
- Shawn
MCP, VB6: Desktop Apps
[ C# | VB | .NET | Java | VC++ | Perl | PHP | Javascript ]
Unless otherwise stated, all sample code provided is UNTESTED.
http://www.codemastershawn.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|