Back in the days of Web Forms, there were server controls, and they generated rather CSS-unfriendly HTML. So, Microsoft got someone (Russ Helfand) to write adapters that changed their rendering to be more CSS-friendly: the “CSS Friendly Control Adapters” were born.
A little less farther back, in 2007, I tried convincing some people at Microsoft to let the community continue development of these adapters, and they agreed. The CSSFriendly CodePlex project was born, and a bunch of bugs and some new features were added.
A lot has changed since then, but the adapters still have use today for people stuck on .Net 2.0 (they’re in the top 200 most downloaded CodePlex projects, and their forums still see activity). To facilitate those who still use CSSFriendly, I’ve added the library package to NuGet.
How to use the CSSFriendly NuGet package
In four easy steps (three if you already have NuGet).
- First, you need Visual Studio 2010 and NuGet. (If you’re new to NuGet, read the getting started documentation.)
- Next, right-click the References folder and choose Add Library Package Reference.
- In the Add Library Package Reference window, search for “cssfriendly.”
- When you see the CSSFriendly package, click the Install button.
After it installs, the following is added to your project:
- The CSSFriendly library reference
- The CSSFriendlyAdapters.browser file in the App_Browsers folder
At that point, you’re ready to go!
The full source of the CSSFriendly library is still available at CodePlex: http://cssfriendly.codeplex.com. Downloads there include sample code and walkthroughs.
Enjoy, and let me know if you have any issues!
Over the past few weeks, I started doing some experimentation with a different approach to changing the rendering of default ASP.Net controls. For a few years, I (and many others) have used the CSSFriendly project for this. That project does some nice things, but has many shortcomings.
I hemmed and hawed about this a bit (see Rewriting the ASP.Net CSS Friendly Adapters – does anyone care?), but in the end some fundamental interest — and the underlying popularity of the CSSFriendly project (consistently in the top-20 downloads on CodePlex) made me decide to go ahead with it.
So, I am proud to announce a new open source project: the ASP.Net Control Adapters! Continue reading
A few days ago, I wrote a lengthy post on the official ASP.Net forums where I discussed some thoughts on a new version of the CSS-friendly ASP.Net control adapters. In the post, I outlined some new approaches to improve testability and configuration.
Since that post (written on the evening of Sept 16), there have been no replies, which leads me to consider a few possible realities…
- No one reads the ASP.Net forums. (Not true; the post was read at least 79 times, as of this writing.)
- No one posts on the ASP.Net forums. (Not true; other posts were written since my post.)
- No one uses the CSS Friendly adapters. (Not true; they have been downloaded over 1,800 times in the last week, according to CodePlex — making it the 14th most popular CodePlex project in that time.)
- No one cares about rewriting them.
- No one who cares about rewriting them reads the ASP.Net forums.
OK, so either no one cares about improving on what we currently have, or no one who cares saw my post. Which is it? Do you use the CSS adapters? Would you use them if they were improved?
If you’ve used the CSS Friendly ASP.Net Control Adapters in the past, you may want to check out change set 9278, which included a number of improvements to the GridView, DetailsView, and FormView controls.
From the check-in notes:
– Major rewrites of GridView, DetailsView, and FormView walkthroughs
– FormView and DetailsView now use PagerTemplate when it exists
– FormView, DetailsView, and GridView properly position pager based on PagerPosition and Visibile properties
– Implemented GridView’s DataControlRowType.Pager instead of hard-coded CSS class (non-breaking change)
The new test “walkthru” pages are quite useful. You can now set the control options and see the results of the change immediately without having to modify the code in the ASPX file. Implementing the test pages this way made it much easier to evaluate if the control adapters were doing what they were supposed to do.