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) :…
![](../../users/profiles/321946.webp)
RPM1984
- 69,608
- 55
- 212
- 331
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…
![](../../users/profiles/283739.webp)
Deniz Dogan
- 23,833
- 33
- 104
- 154
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…
![](../../users/profiles/347849.webp)
Andy Evans
- 6,195
- 17
- 62
- 112
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…
![](../../users/profiles/325139.webp)
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 =…
![](../../users/profiles/84791.webp)
MarkKGreenway
- 7,534
- 5
- 31
- 50
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…
![](../../users/profiles/247241.webp)
Roger Rogers
- 525
- 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…
![](../../users/profiles/240424.webp)
Yakimych
- 16,939
- 7
- 46
- 66
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…
![](../../users/profiles/85411.webp)
Ozzie Perez
- 553
- 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…
![](../../users/profiles/938273.webp)
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...
…
![](../../users/profiles/729820.webp)
SoftwareSavant
- 8,456
- 26
- 107
- 186
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 =
…
![](../../users/profiles/729820.webp)
SoftwareSavant
- 8,456
- 26
- 107
- 186
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…
![](../../users/profiles/790922.webp)
michael
- 525
- 2
- 13
- 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…
![](../../users/profiles/300485.webp)
user300485
- 525
- 5
- 10
- 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…
![](../../users/profiles/351709.webp)
David
- 5,013
- 14
- 38
- 65
1
vote
2 answers
ASP.net validation: why do my DateTime fields also flag up as required?
I'm implementing validation in my web app... the problem is it seems to be over-validating?!
The controller code looks like:
[HttpPost]
[Authentication]
public ActionResult Create([Bind(Exclude = "Id")] CaseInfo caseInfo)
{
if…
![](../../users/profiles/433145.webp)
laura
- 2,881
- 9
- 40
- 61