Take total control over the head tag in ASP.NET

by timvasil 10/22/2008 2:44:00 AM

When you use the tag, such as on a master page, the HtmlHead control does the rendering work. The results are pretty dreadful; spacing is pretty screwy for one thing. But that's something I can live with.

One thing I can't live with, however, is third party components like DevExpress adding bogus (and redundant!) stylesheet links within the head tag! I wanted to take control of that tag to filter out these tags, but found HtmlHead to be a sealed class. I can't tell you how many times I've tried to correct bad behavior through the well-established OO practice of inheritance only to find a "sealed" wall in my way. Personally, I think that keyword needs to go! But, alas, in this case there is a way to get around the constraint.

I didn't realize this until today, but ASP.NET has a mechanism for overriding how a control renders its content, even if that control is sealed. The magic is in browser adapters. I learned all about it here:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET

Related posts

Comments are closed

 

About the author

Tim Vasil Tim Vasil
I'm a software engineer living in Cambridge, MA.

E-mail me Send mail

Search

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Recent comments