I don't understand what you're asking.

Do you want something like

let addValidation (tb:TextBox) =
tb.Validating.Add(fun cancelEvent ->
cancelEvent.Cancel <- not(ValidateVerField yadda yadda))

addValidation majorTextBox
addValidation otherTextBox
...

?

By on 4/21/2010 10:50 AM ()

Hi Brian,

Yep--just tried it. You were right on the money.

It's hard to switch my thinking from the OO mindset (hang the same function on several objects) to the more FP approach (build one function to operate on several objects) but in this particular case your approach is obviously better than what I'd come up with.

Thanks again.

By on 4/23/2010 8:54 AM ()

For not understanding what I'm asking, Brian, you did pretty well. :-)

I think that's pretty much exactly what I need to do. As I said, four text boxes and I had the same validation code on all four. I've been at coding long enough to learn to hate the smell of duplicated code.

The thing that was confusing me was the cancelEvent eventargs object. I think your approach is pretty slick.

By on 4/21/2010 3:33 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper