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.
Questions tagged [asp.net-mvc-2-validation]
80 questions
2
votes
1 answer
ASP.NET MVC 2 Model Errors with Custom Exceptions
I have a custom exception class:
public class MyException: Exception
{
public MyException(MyExceptionEnum myError) : base(myError.ToDescription()) { }
public MyException(MyExceptionEnum myError, Exception innerException) :…

RPM1984
- 72,246
- 58
- 225
- 350
2
votes
1 answer
ASP.NET MVC: DropDownList validation
Note: The following is just an example.
I'm pretty new to ASP.NET MVC and I'm trying to get my head around how validation of dropdown lists work. I have the following property in my ProfileViewModel class:
[DisplayName("Gender")]
public bool? Gender…

Deniz Dogan
- 25,711
- 35
- 110
- 162
2
votes
1 answer
MVC 2 - How to exclude multple columns in the create method
How can I exclude multiple columns when creating a new customer? The other column is the date that the record was created - called customer_dt.
public ActionResult Create([Bind(Exclude = "customer_id")] Customer customer)
{
/* Do something here…

Andy Evans
- 6,997
- 18
- 72
- 118
2
votes
1 answer
client side validation in ascx files (user controls) for asp.net mvc
I have a logOn forn in ascx files and I render it as partial.
How I can add a clinet side validation to this form, have any idea ?
My below code does not work
<%= Html.ValidationSummary(true, "Giriş başarısız oldu. Lütfen hataları düzeltip tekrar…

Sefer K
- 504
- 1
- 5
- 19
2
votes
1 answer
ASP.NET MVC 2 "value" in IsValid override in DataAnnotation attribute passed is null, when incorrect date is submitted
This is my first question here on stack overflow.
i need help on a problem i encountered during an ASP.NET MVC2 project i am currently working on.
I should note that I'm relatively new to MVC design, so pls bear my ignorance.
Here goes :
I have a…

goldenelf2
- 65
- 6
2
votes
2 answers
Generating Data Annotations from Generated Classes
I have a linq to sql object or if neccessary Entity Framework object.
I want to do MVC 2 Data Annotations for them, but I am endlessly lazy.
Is there a way to automatically generate the data annotations a-la
[Bind(Include =…

MarkKGreenway
- 8,494
- 5
- 34
- 53
2
votes
1 answer
How can I validate a multiselect in MVC2 form?
This seems like a really basic scenario, but I think it doesn't have a happy ending.
I have a simple project class:
public class Project
{
[Required(ErrorMessage = "Project title is required")]
[DisplayName("Project Title")]
public…

Roger Rogers
- 535
- 1
- 4
- 15
2
votes
2 answers
ASP.NET MVC 2 RC 2 "Wizard" for whole model validation
There is a good simple solution for a multi-page "Wizard" control in MVC…

Yakimych
- 17,612
- 7
- 52
- 69
2
votes
1 answer
ASP.Net MVC 2 RC: How To Use Client Validation with Data Annotations for Lists?
My problem:
I can't get Data Annotations Client Validation to work with a List in my viewdata class.
The skinny:
In my view data class I have a List.
public class FriendsViewData
{
public List people { get; set; }
}
I have all the…

Ozzie Perez
- 583
- 2
- 8
- 17
1
vote
2 answers
Regex regular expression coordinates
trying to sort out a regular expression for the following string:
51.4920302, -0.0850667
So far I have:@"^[0-9]*,{-}[0-9]*$" but it doesn't seem to be working.
Any thought, greatly received.
The whole snippet…

sald
- 21
- 1
- 4
1
vote
1 answer
Jquery Validation and MVC2 dumb question
I am trying to do some basic Jquery Validation in my MVC2 project and I keep getting this error...
Microsoft JScript runtime error: Object doesn't support property or method 'validate'
Even before the page loads at this simple script...
…

SoftwareSavant
- 9,467
- 27
- 121
- 195
1
vote
1 answer
Impersonation: call only once or keep calling per cient call MVC2 callng -> WCF
When Impersonating a client to a web service, do I need to call it once, or do I need to call it several times, each times I call the client essentially.
client.ClientCredentials.Windows.AllowedImpersonationLevel =
…

SoftwareSavant
- 9,467
- 27
- 121
- 195
1
vote
3 answers
how to validate dropdown optionlist required functionality asp.net mvc
I have dropdown like this ,
<%= Html.OptionList("Worktype", new SelectList(new List{
new SelectListItem{Text = "--Select One--", Value = "0", Selected=true},
new SelectListItem{Text = "Fulltime", Value = "Full Time"},
new…

michael
- 575
- 2
- 14
- 27
1
vote
3 answers
Zip Code validation using MVC2 in asp.net mvc
[Required(ErrorMessage = "Please Enter AccountZip Code!")]
[RegularExpression(@"/(^\d{5}(-\d{4})?$/", ErrorMessage = " Zip code must be 5 characters length")]
public string AccountZip { get; set; }
I did regularexpression…

user300485
- 525
- 5
- 11
- 24
1
vote
1 answer
Client Side Validation Not working for custom Attribute
Hi
I have a custom Attribute
public class NameAttribute : RegularExpressionAttribute
{
public NameAttribute() : base("abc*") { }
}
This works on the serverside but not in the client side but…

David
- 5,403
- 15
- 42
- 72