Questions tagged [asp.net-mvc-2-validation]

The ASP.NET MVC 2 modelstate validation checks if a model is valid. You can define a correct model state and check if the users input matches that validation.

80 questions
3
votes
5 answers

What's the recommended place to perform validation: ViewModel, Model or Controller?

I have a registration page and would like to perform some validation (in addition to the StringLength and Required annotations on my ViewModel) for duplicate usernames and email addresses. Currently I perform this validation in my controller when…
b3n
  • 3,805
  • 5
  • 31
  • 46
3
votes
2 answers

Detect if asp.net mvc2 client side validation passes or fails

All... I am working in a asp.net mvc2 project using MicrosoftMvcValidation... I have some custom javascript that I need to run when a form gets posted... I am currently running this code when the submit button is clicked. However, when the client…
Todd
  • 1,461
  • 2
  • 13
  • 27
3
votes
0 answers

MVC: Client Validation Fails, but data is still posted

As above, I'm implemented the client side validation no problem, and it pops up the relevant messages as required. However, the submit button still appears to submit the form even though the form is not in a valid state. The controller method…
Gavin
  • 2,321
  • 3
  • 19
  • 21
3
votes
2 answers

Handling 'A potentially dangerous Request.Form value was detected from the client'

I am trying to figure out how to handle this error. A potentially dangerous Request.Form value was detected from the client The error occurs when a user enters in html or xml tags(

or ) and tries to submit a form. The input is not…

Mikael
  • 95
  • 1
  • 2
  • 7
3
votes
1 answer

ASP MVC2 model binding issue on POST with strongly-typed HTML helpers

So I'm looking at moving from MVC 1.0 to MVC 2.0 RTM. One of the conventions I'd like to start following is using the strongly-typed HTML helpers for generating controls like text boxes. However, it looks like it won't be an easy jump. I tried…
3
votes
1 answer

Client-side validation with a model-less view in ASP.NET MVC 2

I'd like to use the new client side validation features in MVC 2 but I have a particular view that just has a couple textboxes on it and I don't want to create a strongly typed model for it. Can someone describe how to leverage the validation…
James Alexander
  • 6,132
  • 10
  • 42
  • 56
3
votes
2 answers

ASP.NET MVC 2 client-side validation rules not being created

MVC isn't generating the client-side validation rules for my viewmodel. The HTML just contains this: