If you have the problem that your text field validation gets generated althoug there is no Required attribute set on property, use the next code in the Application_Start to force the compiler to validate only if there is a required attribute on the property:
// Whit this line of code you will remove data-val-required
DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
// With these two lines you will remove data-val-number and data-val
ModelValidatorProviders.Providers.Clear();
ModelValidatorProviders.Providers.Add(new DataAnnotationsModelValidatorProvider());
This is a blog where you are going to find tips or solution that are going to be helpful in the technology environment.
Wednesday, September 24, 2014
Thursday, September 11, 2014
ASP.NET MVC Razor Override "id" and “name” attribute with TextBoxFor
Use the code below as example to override the id or/and name attributes with TextBoFor, something really important to keep in mind is that "id" and "Name" is case sensitive.
@Html.TextBoxFor(x => x.Data, new { Name = Model.Name + "_Custom", id = Model.ID + "_Custom" })
Subscribe to:
Posts (Atom)