views:

914

answers:

2

Hi,

I am wondering what methods people are using for validating check boxes in ASP.NET MVC (both client and server side).

I am using JQuery currently for client side validation but I am curious what methods people are using, ideally with the least amount of fuss (I am looking for a new solution).

I should mention that I am currently using MVC Preview 4, and while I could upgrade to MVC Preview 5 if there is no elegant solution in MVC Preview 4, I would prefer not to at this stage just for compatibility purposes with other developers and existing solutions.

Note, I have seen these related posts:

+1  A: 

I assume you simply check whether or not the name of the checkbox was posted to the server or not. Not being an ASP coder myself, I can't help, though this is how it would be done in PHP (of course, depending on how you map validations).

<?php echo isset($_POST['checkbox_name']) ? 'checked' : 'not checked'; ?>
Tom R
Yeah, that's pretty much what I'm doing now. I'm more looking for a solution that ties in more automatically with the framework and model rather than manual checks on every field.
Graphain
+1  A: 

Hello, If you go on to the validation website and download the whole package that included the demo files, you can find the one with example of validating check boxes and radio buttons. The link is here: http://jquery.bassistance.de/validate/jquery.validate.zip

Cheers. Guess I need a framework that's nicely tied with the jquery validate for server side now.
Graphain