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.
Implementing a custom model validator (for server-side validation — client-side validation requires more than is covered in this post), you need to write an implementation of the ModelValidator and ModelValidatorProvider classes that support the Castle Validators.
An example of how to do this follows. Though it hasn’t been fully tested, it worked for a handful of situations I experimented with. Use this as a starting point for your own server-side model validator implementation. Continue reading →
I tend to create new Visual Studio projects using the class library template, then make it into what I want. Sometimes, what I want is a web project. Through the project properties view, you can change a project between a class library, windows application, or console application with ease — but there’s no easy way to change to a web project.
Fortunately, there is an easy way to do it.
Open your VS2005 project file (ending in .csproj) in a text editor. Add a new line (shown below) to the first , usually one of the first few lines in the file.
Save the file and reopen your project. Viola! It’s a web project. But there is a bit more to do. Find each <OutputPath> line, and set remove the Debug or Release (or any other) folder, so it just reads as follows.
Since starting with MonoRail some months ago, I’ve joined the bandwagon touting its benefits over Web Forms. Part of my advocacy was to convince the developers who help me out with my online baseball game, CSFBL (which will be rewritten using MonoRail).
In a discussion on our BaseCamp site, one of those developers, Rick, said this. (Emphasis added by me.)
I finally got to spend some time with MonoRail on Friday at work… [T]he guy that sits next to me does dev work on a fairly complex ASP site… He’s just got tasked to add a whole new section of his site and he doesn’t want to do it in ASP and we both got tasked to start learning each others projects so that we can back each other up when one of us is out so we decided to give MonoRail a look. He had spent all week just trying to get up to speed on ASP.Net and he was getting very frustrated… we spent about an hour going through the first tutorial before we both got interrupted to do other things, but we liked what we saw so far. We plan on picking up right where we left off first thing Monday morning.
I read your latest blog post about MonoRail vs ASP.Net and I’m one of those coming from the VB background that found Web Forms easy to learn. But after looking at all your links and the demos I can’t wait to learn this stuff. You nailed it on the head at the end when you said you’d rather learn this than fight with the GridView… that’s the part of Web Forms that I hate. I can’t count the hours I’ve wasted on the old DataGrid in ASP.Net 1.1 and my coworker spent all week fighting with the Wizard and GridView controls.
Cool stuff. 🙂
Cool stuff, indeed. Unfortunately, it’s not so easy to convince everyone. Here’s a follow-up reply he made. Again, emphasis added is mine.
My reply went something like this.
The good thing about all of this is we have options: Web Forms, MonoRail, and many others. What’s better for one person (or one project) is not necessarily better for everyone (or all projects). People should try different solutions, and ultimately choose the one based on what are you most comfortable with and what makes you a better, more efficient developer.
I think that one’s attraction (or hatred) of MonoRail or ASP.Net’s WebForms is based on their programming background. (At least, it is in my case, and that’s at least one person, so that statement can’t be totally wrong.)
People who come from the old days of Visual Basic programming or whose experience with web programming is WebForms and ASP.Net will feel comfortable with ASP.Net.
For all its flaws, WebForms has a lot of power, but the power comes at a price. Web forms does a lot for you, which is its benefit and its bane. If you want total control of your application, you’ll be frustrated with WebForms. MonoRail leaves a lot of things in your hands (particularly on the presentation side), and tries to help you do things rather than do things for you. That’s a big difference.
One of the reasons for the popularity of ASP.Net and WebForms (aside from Microsoft, of course) are the many web controls that come built-in or that you can buy to extend your application’s capabilities without having to write your own complex code. The same issues described above, however, still apply. Whenever you rely on a web control to do a complex task for you, you’re sacrificing some control.
That’s not to say there are no "web-control-like" solutions for MonoRail. There are many community-developed scripts and code blocks that can be used to extend the functionality of a web site built on MonoRail, providing features similar to web controls with less mysterious baggage. Consider the following.
David Hayden, who admittedly is very familiar with WCSF and not very familiar with MonoRail, touts the future of WCSF and the concerns about the lack of resources working on MonoRail in order for it to compete long-term.
Scott Bellware talks about evaluating MonoRail for an enterprise application, and he mentions his horrible experience setting up and comprehending WCSF.
Hammett, one of the key Castle Project people who admittedly is not familiar with WCSF, talks about the need for WCSF to compete with MonoRail, not the other way around.
Where do I stand? Before answering, I need to explain my history with web development, ASP.Net, and MonoRail.
I started doing web development in the late 1990’s coding by hand and using ColdFusion on the server-side. I migrated to ASP and, ultimately, to ASP.Net, as most people did.
When I stumbled across MonoRail some time in 2006, I liked what I read, but didn’t have the time to explore it further. Towards the middle of 2006 I was working on my own Model-View-Presenter web architecture that was simple but effective, and even started transitioning my only claim to fame, CSFBL, to it. Then, I decided to give MonoRail a try.
Back in late 2006, I modified Microsoft’s CSS Friendly ASP.Net 2.0 Control Adapters to be distributable as a single DLL. Since that time, the code I wrote was downloaded from this web site, and everything seemed good, at least until the server crashed. After being prodded by a few people in the ASP.Net community, I moved this little project over to CodePlex. Before doing so, I checked to make sure this was OK with Scott Guthrie, the grand poohbah of ASP.Net at Microsoft. (You’ve got to cover your basis!)
Anyway, today I read a post on the ASP.Net forums stating that Microsoft OKs community development of the CSS Friendly Control Adapters. In short, this is a good thing for the users of this product, for reasons that are explained in that thread, and it looks like I’ll be more involved with the ongoing development of these adapters in the future. It’s also nice to see your efforts noticed by the largest software development company in the world. 😉
I will keep the pages on this site that mentioned these adapters, but I highly suggest everyone who used them to bookmark the CodePlex project “CSSFriendly” and use that as their source of code and information going forward.
Last week, I released a compiled version of Microsoft’s CSSFriendly ASP.Net 2.0 Control Adapters (“CSSFriendly”). Since that post, the “1.0” RTM version of the adapters were released. I just finished porting the latest release to a compiled assembly.
Instructions for installing and using the compiled adapters, and download links, can be found in the Projects section of this web site.
UPDATE: Added a link to download just the DLL at the bottom of the entry, and rewrote some of the “implementation” steps to make them a bit clearer.
I’ve been following the progress of the CSSFriendly ASP.Net 2.0 Control Adapters (“CSSAdapters”) since they were initially launched some 6+ months ago. The team has continually worked on revising them (with a little help from me), and the latest release (Beta 3.0) seems to be something that we can live and work with comfortably.
One thing I’ve hated about the adapters is the implementation, which basically involves the following steps:
Add a file to the App_Browsers directory.
Add a folder of CSS files.
Add a bunch of files to the App_Code directory
tags to the section of your web pages (to import the stylesheets and handle some conditional imports for IE6 and IE7).
Apparently, I’m not the only person who thinks there should be an easier way, and it seems that the folks working on the CSSAdapters agree (see the Serving Suggestions topic on the ASP.Net forums).
Inspired by the posts in that topic (especially the post by HardyE), I present to you a fully-compiled version of the CSSAdapters (Beta 3.0). A few notes on the implementation follow.
The only CSS files embedded are those that actually do anything. In other words, I removed all but the following: DetailsView.css, Menu.css, TreeView.css, IEMenu6.css, and IEMenu7.css.
To get the CSS files to link (required for the MenuAdapter, TreeViewAdapter, and DetailsViewAdapter), I added code to the RegisterScripts() method to reference the CSS file as a Web resource (using GetWebResourceUrl()). Adding them to the web page was done by parsing a
Implementation of the compiled CSSAdapters in a web site requires the following steps. Note that only the first step is the same as those listed above; steps #2 through #5 are eliminated by the “new” step #2 below.
Add the appropriate file to your App_Browsers directory (this step doesn’t go away, and it shouldn’t, because essentially this is a configuration file).
Add the compiled CSSAdapters.dll to your web site’s bin directory.
This makes it much easier to implement and manage than before. Note that this implementation wasn’t heavily tested, but it worked flawlessly with the CSSAdapters demo app (which is included in the distribution I’m providing here). Let me know how it works for you, or if you have any problems or suggestions.
Yesterday, while starting up my PC out of hibernate mode (an activity done about 250 times before), after entering my username and password, Windows stared at me with a blank blue screen and a task bar (i.e. the desktop color and nothing else). Windows was certainly doing something, because the disk was thrashing. This went on for about five minutes. No activity on my part (CTL-ALT-DEL, CTL-SHIFT-ESC for Task Manager, etc.) brought about a response during those five minutes. After banging my keyboard countless times (it’s amazing I don’t break more than one a year), Windows suddenly sprang into service as if nothing out of the ordinary happened.
Can someone please tell me what the #&^$&#^ Windows was doing during those five minutes, and if it was such a mission-critical operation that NO OTHER ACTIVITIES could be taken while they ran, why there is no notice in the event log? Heck, a progress bar or meaningless popup message would have been nice.
Today, I attempt to hit the F1 key to get “help” in Visual Studio 2003 (yes, we all need help sometimes). VS2k3 has been run many times in the past, and I keep it up-to-date with the latest MSDN updates (i.e. the occasional help file updates). After pressing F1, Windows Installer pops up. Deciding to give up all hope on getting the help I need (and understanding that a random Internet search is faster than Windows Installer), I click Cancel. After about four minutes, the “Canceling…” message disappears, replaced by a new “Please wait while Windows installs…” message. I click cancel again. I shut down Visual Studio. The Windows Installer finally ended it “canceling” process after ten minutes, and I have a new message on my screen: “Microsoft Development Environment has encountered a problem and needs to close…” Yeah, yeah. Thanks for nothing.
It’s amazing how Microsoft can do so many things well, yet can’t do some of the most important things right — like make a responsive operating system. Then again, I shouldn’t expect much more. After all, this is a company that delivered an excellent development framework (.Net) yet decided that the framework includes platform-specific implementations (now that WinFX stuff is a “core” part of .Net). It’s funny how I spend a good part of my development time customizing built-in ASP.Net controls to do what I want them to do and not do what they were designed to do.
My three biggest complaints with ASP.Net, in no particular order…
The insistence on formatting with TABLEs (which is finally being addressed with the CSS adapters).
The single-form limtation of ASP.Net, the dependency on ViewState, and the whole rely-on-postback model (which translates fine to some applications but terribly to others).
The general goal of not expecting developers to write code. I want to write code — I want to control my application. Enhanced ASP.Net controls (things like GridViews) should be add-ons, much like you buy a component library from a company like ComponentArt (whose WebUI suite I use often). Microsoft can make them if it wants to, but don’t force-feed it on everyone.
Yeah I know that was four, but I’m a bit peeved by Microsoft today. 🙂