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

  • Thread starter Thread starter Guest
  • Start date Start date
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!
 
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
 
Back
Top