Best practice for creating a user control base class in asp.net 2.

G

Guest

Are there any possible issues with creating a base class (adding common
properties) for a user control using a class file and not a user control
(.ascx and code-behind) in asp.net 2.0? I have successfully tested using a
class that inherits UserControl and it seems like the best way to go but a
co-worker read somewhere that you shouldn't use a base class for user
controls but to only use another user control for the base class. This
process seems sloppy to me since in the end you have an empty .ascx file that
doesn't seem to do anything.

Thanks!
 
K

Karl Seguin

I use a base user control class....I'd like to see the article ur coworking
is refering to...

Not that you asked, but this is the one I just wrote a couple days ago, i
LOVE it:

public abstract class DevelopmentUserControl : UserControl
{
#if DEBUG
protected override void OnInit(System.EventArgs e)
{
CachePolicy.Duration = TimeSpan.FromSeconds(0);
base.OnInit(e);
}
#endif
}


it uses the new programmatic caching in 2.0 to override the OutputCache
while developing. I hate having output cache on while developing 'cuz most
of the time you want to see changes right away. Any control which inherits
from this class won't be cached while in DEBUG. When not in debug, the
normal Outputcache behaviour takes over.

Karl
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top