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
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
  • 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…
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…
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…
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 =…
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
  • 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…
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…
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
  • 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 = …
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…
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…
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…
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…
laura
  • 2,881
  • 9
  • 40
  • 61