Tagged Questions
0
votes
2answers
50 views
.Net Data annotation and model hierarchy
everyone! I'm confusing with implementing a piece of code to make work .net data annotation in asp.net mvc 3 with model with different required fields in several cases (6).
I have a model:
public ...
0
votes
1answer
25 views
ASP.NET MVC “compare” validation doesn't work properly
I have a compare validation for a password - confirm password fields and also a server validation to check if the password fits with a minimum number of characters.
View:
@Html.PasswordFor(model ...
0
votes
1answer
16 views
asp.net data annotations field length
I currently have the following data annotation on a field
[StringLength(1000, MinimumLength = 6, ErrorMessage = "field must be atleast 6 characters")]
public string myField {get;set;}
Can I change ...
2
votes
1answer
457 views
ModelState.IsValid always returns true
I have the following action method:
public ActionResult SignUp(Player player)
{
if (ModelState.IsValid)
{...}
}
The problem is that ModelState.IsValid always returns true even ...
0
votes
2answers
58 views
Get error message when using custom validation attribute
I'm using the CustomValidationAttribute like this
[CustomValidation(typeof(MyValidator),"Validate",ErrorMessage = "Foo")]
And my validator contains this code
public class MyValidator {
public ...
0
votes
5answers
174 views
Is it possible to use a variable for the `[Display(Name=“Something”)]` data annotation in MVC3 (C#)
not sure why, but the data annotation in MVC3 insist on having constant values, which i just can't understand for things like error messages and display names. I love these annotations, they are so ...
0
votes
2answers
60 views
MVC3 validation with data-annotation?
Is it possible to use a data-annotation attribute for dropdownlists to be valid, only if the user selects an option different from one with the value o (zero).
The option with value o (zero) is ...
1
vote
2answers
383 views
Change, override, replace, asp.net MVC 3 default DataAnnotations Validations messages for required and invalid values
I have:
public class StudentDto
{
[Display(Name = "Data de Nascimento")]
public DateTime? Born { get; set; }
}
I'm using jQuery datepicker, and whenever i put an invalid data, the ...
0
votes
2answers
111 views
MVC3 client validation in partial view
I have a view Index and a Partial View SCItems. I use data annotations for validation. It works in Index, but not in my partial SCItem. I should use jquery validation? Thanks.
SCModel code:
using ...
0
votes
1answer
101 views
ASP.NET MVC 3 - Custom client side validation not working
I'm trying to implement a custom client side validation, but it is not working. I'm basing myself on the article on Codeproject ...
0
votes
1answer
57 views
Date validation in “Data Annotations Extensions MVC3” not working properly
I am using the date validation included in "Data Annotations Extensions MVC3" in a Razor C# project with Telerik MVC Components but it doesn't work properly. The validation fails for the "19.09.2012" ...
5
votes
3answers
78 views
Is it possible to force the currency for an MVC3 field with DataType as DataType.Currency
I'm writing an MVC3 application that reads in a bunch of monetary data from a database. The issue I have is that these amounts are all in different currencies.
If I set the type of a field like this:
...
1
vote
3answers
450 views
How to programatically turn on/off a Data Annotation Validation Attribute
So, I am using ASP.NET MVC 3 and Entity Framework 4.1 (code-first).
I have a class like this:
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
...
0
votes
1answer
69 views
ASP.NET MVC Regular Expression for Username is not working correctly. or Convert Regex->JS
I have added a regular expression from a site to verify user name and and it should work but it is giving some error on the compile time. Please see the image and then I googled and learned that few ...
3
votes
2answers
5k views
ASP.NET MVC 3 - Data Annoation and Max Length/Size for Textbox Rendering
I know on the Razor View file, we can do something like this
@Html.TextBox("username", null, new { maxlength = 20, autocomplete = "off" })
However, I am hoping to create a model for the MVC that can ...