Questions tagged [model-validation]

Model Validation is ASP.NET MVC validation method for your models with property attributes. Model validation works for client and server side validation.

For further information you can check Scott Gu's blog post: http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx

There is a expansion called "DATA ANNOTATIONS EXTENSIONS" for other custom validation types such as CreditCard, min-max integer value etc. http://weblogs.asp.net/srkirkland/archive/2011/02/23/introducing-data-annotations-extensions.aspx

325 questions
0
votes
1 answer

Model Validation without the ValidationSummary?

I have a LoginModel for my Login Action, but I'm wanting to use just HTML. Example... public class LoginModel { [Required] public string Email { get;set; } } in my HTML, I have This is because I'm…
0
votes
1 answer

ValidateInput(false) still trigger the validation in IValidatableObject

I have a controller which I dont want to validate, when called upon. My controller: [Authorize(Roles = "Admin")] [HttpPost] [ValidateInput(false)] public ActionResult Delete(MyLINQClass model) { // Do something } My…
Martin at Mennt
  • 5,677
  • 13
  • 61
  • 89
0
votes
0 answers

pdp partial dependence plots rpartscore partial funtion with probability function

I am trying to compute partial dependence plots for model validation of my rpartscore model. when I use my partial(big.tree, pred.var = "VBT",prob=T, plot = T, type = "regression", smooth=TRUE) I get a graph predicting the values but I actually…
Sofia
  • 75
  • 1
  • 7
0
votes
1 answer

Problem with binding to double value from view form to model property in ASP.NET Core

I have a little problem. In ASP.NET Core, in view in form I want to enter double value with decimal point (in Czech with dot) and it doesn't want to take either one (for dot: the value '1.5' is not valid for... for comma: the field .... must be a…
0
votes
0 answers

ASP.NET Core 7 Razor model custom validation - comparing 2 dates not working

I have 2 binding fields in a Razor page as shown below: CSHTML.CS [BindProperty] [Required(ErrorMessageResourceType = typeof(MsgsResource), ErrorMessageResourceName = MandatoryFld)] [CompareDate("DateTo", ComparisonType.LessThanOrEqualTo,…
0
votes
1 answer

TryValidate and manually set values in cotroller (ASP MVC 3)

I have a "New user" form both for admins and for regular users. Both form use the RegisterModel public class RegisterModel { [Required] public string Name { get; set; } public string Email { get; set; } [Required] public string…
Martin at Mennt
  • 5,677
  • 13
  • 61
  • 89
0
votes
1 answer

Customizing Model Validation Feedback

I want to change the way a validation message appears to the user in my nopCommerce web application. Currently, it appears as so: I want to change that, so that if and when the login credentials are incorrect, the input fields get a red border, and…
J86
  • 14,345
  • 47
  • 130
  • 228
0
votes
0 answers

Why does ASP.NET Core 7 MVC ModelValidator always set ModelState.IsValid to true when the Model is invalid

I'm converting an ASP.NET 4.8 MVC web site to ASP.NET Core 7 MVC. I'm running into a problem with ModelValidation where my ModelState is always valid, even when it is not. I'm using the pattern that was used in .Net 4x and worked fine. Microsoft…
0
votes
0 answers

Validation errors showing before filling the model ASP.NET Core

I am still new with ASP.NET Core and I have the following problem. I want to make a Hotel webpage and of course one of the main functionalities is Adding Reservations. And I have the following problem: I have a View Model, 2 actions in the…
0
votes
1 answer

How to return multiple ValidationResults

I am implementing IValidatableObject. In my Validate function, I want to return multiple ValidationResults. How is the best way to go about this? public IEnumerable Validate(ValidationContext validationContext) { …
HoboJeff
  • 101
  • 1
  • 1
  • 8
0
votes
1 answer

Does fluent API IsRequired() does exactly the same as [Required] attribute over the property?

If I put [Required] attribue over a property in a model then the helper tag will throw out a validation error if no value is provided, but also it will be affecting database structure. However does this modelBuilder.Entity(e => …
Yoda
  • 17,363
  • 67
  • 204
  • 344
0
votes
0 answers

C# TryUpdateModelAsync doesn´t work as expected

I´m following this tutorial from Learn Microsoft and I have a problem I don´t know why... I just followed Step by Step (just change project name and context) but doesn´t work for me. Everything is fine until I have this piece of code in the…
datecasp
  • 1
  • 2
0
votes
0 answers

Blazor server model localization

I apologize for the possible incorrectness of the translation (I use a translator). I have been trying for a long time to solve the problem of localization and globalization in Blazor Server. I have had successful localization experience in ASP.NET…
0
votes
0 answers

Model Validation without checking Integer

I don't want to check StudentID. I just want only StudentName validation. But when I am running the code it is showing me the validation of both properties.How can I solve this problem public class Student { public int StudentID { get; set; } …
0
votes
1 answer

Model Validation in .Net Core

Are the DataAnnotations executed in the same order as they are specified or in a random order. Example : public class Model1 { [Required] [Range(3,45,ErrorMessage="out of range")] [emailaddress] public string email_id…
Phaneendra
  • 103
  • 9