home links tools blog about

AngryPets Blog

home

And then it hits me: where are the validators?


Seriously, this one boggles my mind.

ASP.NET 1.0 - it was cool right? Because it was unlike ANYTHING we'd seen before in web development. Sure a number of the 'claims' about what it could do aren't being actually realized until two months from now (when 2.0 goes Gold) - but hey, it was a killer paradigm. And what was that paradigm? Simple: To make web development more like rich-client development. To INCREASE the development experience, and therefore provide a framework for rich web apps.

If that's true, then where the hell are the Validator Controls for .NET Winforms?

I'm digging around in 2.0 Winforms and I'm not seeing ANY love here. Oh, I'm sure I could Google for them with instant success. But I still have a hard time believing that Winforms don't have simple validation controls that could be used to validate user input. That floors me. Hell, there's not even a need to worry about client side and server side discrepancies.

How is it that ASP.NET, in order to be more like winforms, has validators, but winforms doesn't? (huh, punk?)

*scratches head*


posted on Wednesday, September 14, 2005 4:03 PM
 

Existing Comments:

# re: And then it hits me: where are the validators? - Posted: 9/14/2005 9:10 PM - By: Chris Frazier
   Not that I'm disaggreeing with you here, but there are some compelling *asp.net like* validators in the genghis library.

Given the fact that there is still the ErrorProvider, they probably felt as if validation was covered. Validation in winforms has sucked the big one for a long time.

P.S. why are you still using CAPTCHA? I haven't gotten one comment spam since installing reverseDOS, and I don't even have the latest version installed. I'm just say'n! ;)


# re: And then it hits me: where are the validators? - Posted: 9/14/2005 8:24 PM - By: Michael K. Campbell
   Yeah, I'm sure that somebody has picked up the slack to provide validators. - I'll check out the genghis library (that and the ErrorProvider - I'm not familiar with that).

Oh, and thanks for calling me on my CAPTCHA. A few people have flipped me crap about that up to this point - the fact that you did it in a comment drove me to go look into my code and find the 3 or so lines I had added to include that thing. It's gone now.


# re: And then it hits me: where are the validators? - Posted: 9/15/2005 10:58 AM - By: Chris Frazier
   Those controls are really just wrappers around the ErrorProvider - the real problem with validation in winforms is that a control needs to *lose focus* before the validating event will fire.

In 95% of the cases that I've come across this is okay (fill out a form, hit the Smak! button, do the deed) but it's that 5% that usually bites you in the ass. (e.g. if you use a button/control that doesn't take focus away from a textbox - try explaining *that* to an end user:)

Good luck man - validation in winforms is a dirty whore of a mistress.


# re: And then it hits me: where are the validators? - Posted: 9/16/2005 7:43 PM - By: Xander Sherry
   Well, there is validation in WinForms, it just doesn't take the form of seperate controls.

WinForms controls (Take the TextBox for instance) have a CausesValidation property, which if set to true, will, at the appropriate time, fire that control's "Validating" event. You just need to write the code for validating that control in the event handler for it's Validating event. In a lot of ways, it's really simpler, cleaner, and far more powerful than the ASP.Net model of using a limited set seperate (and fairly restricted) validation controls.


# re: And then it hits me: where are the validators? - Posted: 9/16/2005 8:32 PM - By: Michael K. Campbell
   Thanks for the info Xander. I'll have to look into those - they do seem to make more sense. I assume that they're also tied into the ErrorProvider, etc.

I'm really, effectively, in the winforms newbie land. I've done VB6 and access forms a bunch - so I get the underlying concepts - but the nuances are tough - especially coming from ASP.NET side.

(But I've got Chris Sells' Winforms book on the way - so that should shed some light on the subject.)


# re: And then it hits me: where are the validators? - Posted: 9/18/2005 4:48 AM - By: Jonathan Silber
   In principle validators DON'T belong in WinForms, while in practice they'd be really useful as reuseable components to add to your form. While I'm no help to you in finding such toys, I still thought I'd weigh in on why they don't really belong in WinForms.
So what truly sets apart ASP.Net as you note is doing web development with the drag and drop/code-snipped ease of IDE-based forms C/S development. The reason this took so long? All the PITA of client-side/server-side and a variable run-time environment (e.g, the client's o/s and browser).
So that's where validators come in - you write .NET code or just set some properties and like magic you get jscript hooked into html page events so that you can do fine-grained operations without returning to the server.
Now WinForms doesn't have thsoe two issues of where to run and what's the run-time. Instead you get great flexibility to choose which events cause validation, and what validation actually does. Plus you get CausesValidation switches on your controls that's a carry-through from VB5/6 forms.

But, if you really want it all to blur together, just hang on a few more months for WinFX and XAML. Then you can pretend there's no difference between client/server and web UI development.


# re: And then it hits me: where are the validators? - Posted: 9/20/2005 11:17 PM - By: Xander Sherry
   The Chris Sells book is a good one. Another that I like, thought it's fairly basic and strictly .Net 1.x is Matthew MacDonald's book on C# WinForms and WinForm controls. It gives a nice look at a lot of the things you can do with WinForms that we never dreamed about in the webdev world. <Grin />
http://www.amazon.com/exec/obidos/redirect?link_code=ur2&amp;camp=1789&amp;tag=xandersherryn-20&amp;creative=9325&amp;path=tg/detail/-/1590590457/qid=1127279578/sr=8-1/ref=sr_8_xs_ap_i1_xgl14?v=glance%26s=books%26n=507846



# re: And then it hits me: where are the validators? - Posted: 9/20/2005 11:20 PM - By: Xander Sherry
   Ehh...Bad link before, I think. Anyhoo, this is the title:
"User Interfaces in C#: Windows Forms and Custom Controls" by Matthew MacDonald, if you're inclined to check it out.


# re: And then it hits me: where are the validators? - Posted: 9/20/2005 11:23 PM - By: Michael K. Campbell
   At this point one of the best things I've done in a while was mouth-off about this here in my blog.

My copy of Chris Sells' book showed up yesterday, and I've not had much time to read it yet, but I can already tell that it's a great book - scanning the sections about validation and error handling have given my brain a bit more to think about - in addition to what all of you kind folks have told me (the ErrorProvide object, etc.)

I should mouth-off more often - I'd learn tons ;)

Thanks for the suggestions everyone (and thanks for the book recommendation Xander - I actually eyeballed that one for a bit...)



Add your own comment:


Go to http://blog.angrypets.com where comments are enabled.