The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
28 views

Maintaining ModelState errors when returning view as a string

I make a number of Ajax calls in my application and sometimes I'm returning views. I've tried to standardize the responses I'm sending back which looks something like this return Json( new ...
0
votes
2answers
33 views

Remote attribute in editor template in asp.net mvc

I have the following two properties in Country class (Model). public class Country { [HiddenInput(DisplayValue = false)] public int Id { get; set; } [Required] ...
0
votes
0answers
24 views

Load Navigation Property by its Key

I am using the EF CF approach and have: the following data model: public class Category { [Key] public int CategoryID { get; set; } [Required] public string CategoryName { get; set; ...
0
votes
0answers
17 views

Multiple RuleSet for a single Model Class with complex properties in MVC

I have a Model class which displays 2 different complex properties of same type as follows :- public class MainClass { public Name CustomerName {get;set;} public Name SupplierName {get;set;} ...
0
votes
1answer
20 views

How to get ModelState Errors at runtime using Key added by ModeState.AddModelError( key,value)

I have added Model error from controller using if( model property not selected) { ModelState.AddModelError("SelectionRequired","Please select atleast one value"); } This error I am adding at many ...
0
votes
2answers
39 views

How can I make a field required only under certain conditions?

I have an Edit view that I use for creating and editing Users. The view has Password1 and Password2 fields, for password and confirmation respectively. These are not marked as required in the view ...
0
votes
0answers
16 views

jQuery/ASP.NET MVC: Does a validator need to be defined?

In my ASP.NET MVC form, I've got a hidden field that holds the primary key of the object I'm editing. Model: public class PropertyModel { public int PropertyId { get; set; } } View: ...
3
votes
1answer
945 views

jQuery.Validation.Unobtrusive client side validation only works when scripts are on view page

I have an ASP.NET MVC 4 App that uses the jQuery.validation.js plugin and MVC's jQuery.validation.unobtrusive.js. I use data annotations on my view model to validate a textbox's input to be an ...
0
votes
1answer
74 views

Razor generates different HTML after published to a shared host

Model class: public class MyClass { ...... [MaxLength(9), Required, DisplayName("Social security number")] [RegularExpression(@"\d{3}-\d\d-\d{4}", ErrorMessage = "Invalid social ...
1
vote
0answers
109 views

Client validation not working on the shared host but works when debugging

I had the following property in model class: [MaxLength(9), Required, DisplayName("Social security number")] [RegularExpression(@"\d{3}-\d\d-\d{4}", ErrorMessage = "Invalid social security number")] ...
0
votes
3answers
194 views

A List of Field Names as a String Array - LINQ Expressions

Hello MVC and LINQ Experts, I have a Model that looks like this: public class SomeClass : IValidatableObject { public string SomeString { get; set; } public string SomeString2 { get; set; ...
5
votes
1answer
1k views

MVC data annotations range validation not working properly

I have a RangeValidator on a property in my model to only allow Integers that are between 0 and 100. I have a partial view that displays a form to update the property via a jQuery UI dialog. I have ...
4
votes
2answers
388 views

ASP.NET MVC Model Validation Error Localization Context

First of all, I have to say that I understand how Data Annotation -based Model Validation works in ASP.NET MVC4 and I have it successfully implemented with DataAnnotationsModelValidatorProvider. So I ...
0
votes
1answer
41 views

Is there a way I can simply use a data annotation attribute to add a JavaScript attribute to a form field?

I would like to add a data-other-for attribute to a text input, to link it to a select, so that it can be used to capture a value not present in the select when the user selects 'Other' in the select. ...
0
votes
0answers
59 views

Rendering unobtrusive validation attributes without LambdaExpression

How can I render unobtrusive tags without using LambdaExpression? I'm using a client side view model that's derived C# viewmodel using JSon to KO mapping. I would like to maintain things as is in ...
0
votes
0answers
52 views

ModelState errors appear in ValidationSummary but not on the page

In an MVC 4 application I've got some custom validation firing that results in the error being written to the ValidationSummary but not on the page (where I have ValidationMessageFor calls). The IDs ...
0
votes
0answers
194 views

How to fire MVC Server Side validations when form is submitted using AJAX?

I have a series of partial views which I am loading on the same page using ajax calls one by one. All the previous partial views are disabled and the new partial view is loaded at the end. I would ...
0
votes
1answer
237 views

MVC3 How to define custom error messages using annotations?

I have a DateTime field(that can accept multiple date time formats, so it is pain to create Regex patter) When in the field I'm entering something like "Aaaaaa", I'm getting error message: The value ...
0
votes
0answers
50 views

Client Validation Conflict - ASP.NET

My website as Masterpage, and in my masterpage I have a Custom Validation to make login and works fine. (With client validation and server validation). But when I make a Custom Validator or Required ...
1
vote
0answers
139 views

Extending MVC FoolProof validation

I would like to use MVC FoolProof Validation in my MVC 3 application. I need a Numeric validation and also accepts N/A or n/a. So i decided to create my own custom validation attribute like ...
2
votes
1answer
149 views

ValidationMessageFor with model and html attribute only - MVC 3

Working on a MVC 3 application. I need to add a class to the validation message html. I mean for span tag. My Model [Required(ErrorMessage = "Role Name is required")] ...
0
votes
2answers
101 views

Hitting a non-character key in an MVC3 required field fires validation?

I noticed that on a log in view, when a user enters in their email address, and quickly tabs to the password field, the MVC3 required attribute validation fires. The code I have is quite large, but I ...
1
vote
1answer
185 views

Regular expression and other validation with MVC 3

I need to implement following validations in MVC 1. Date field A field can accept only mm/dd/yyyy format and should be in a year range between 1753-9999 and other basic checks like Leaf year and ...
-2
votes
1answer
96 views

Better way to check duplicates in the list

I am checking if there are any duplicates while posting list of objects from view to controller by using validation attribute. It works but I would like to know if there is any better approach to ...
1
vote
1answer
172 views

ASP.NET MVC 2 List<T> model validation

I am working on MVC 2 application and I have a problem. My code looks like this: public ActionResult Users() { try { var model = new List<User> ...
1
vote
1answer
386 views

ASP.NET MVC 2 validation on dynamic page

I have registration wizard on my asp.net mvc 2 application with multiple pages. On the first page I should have basic data form of persons involved in the process. I should have 3 text boxes labeled ...
1
vote
1answer
122 views

How to update UI with validation error message with disabled JavaScript?

I have a form: using (Html.BeginForm()) { @Html.TextBoxFor(x => x.Name, new { @class = "span8" }) } Model: [Required] [RegularExpressionAttribute("regex")] public string Name { get; set; } ...
0
votes
0answers
52 views

MVC RemoteAttribute with Image Validation

I am trying to get the ValidationMessage to display an icon on success and fail whenever a user provides an input in the editor and the RemoteAttribute validation is done. I have the following code ...
0
votes
0answers
62 views

RemoteAttribute using validation for more than 1 field

I have been experimenting with the RemoteAttribute, however came across an issue. I have implemented an action method which handles the validation of an email string, however would like to have this ...
2
votes
1answer
379 views

MVC Client Side Validation doing database check

Is there a way how to perform a "database" check through the Client Side Validation in MVC? I have the following class public class EmailCheck : ValidationAttribute,IClientValidatable { ...
0
votes
2answers
88 views

ValidationMessage is showing on initial GET method

I am working on an MVC 4 project that is constantly showing the ValidationMessage even on a simple GET method that does no validation or model binding of complex types: ...
0
votes
0answers
552 views

C# MVC Model Validation - String Length Issue

I am having an issue with my model validation on an MVC web page. When I display a string in a textbox it's length is longer than expected which breaks the validation. I have declared a string ...
3
votes
1answer
3k views

jQuery time picker and MVC validation - the field must be a date

I have a property named StartDate in my model. I have used timepicker add-on to jquery.ui plugin from here. It is working fine, but problem is that I'm getting validation error message. How can I ...
1
vote
3answers
574 views

MVC Validation Fundamentals (with Entity Framework)

MVC Validation Fundamentals (with Entity Framework) Scenario: I have a model class as below (autogenerated via Entity Framework EF.x DbContext Generator). (There is no view model at the moment). ...
0
votes
1answer
809 views

MVC4 validation for select option value

I am new in the MVC technology and I have an MVC 4 application and am trying to display a validation for select input(Month and year). I did validation for input type="text" its working fine for me. I ...
0
votes
1answer
422 views

Validate only ajax loaded partial view

I have a form with some controls. There is a button on the form which loads a partial view. Inside the partial view, there are two required field textboxes along with a button. And when its clicked, I ...
0
votes
1answer
101 views

How to check if a <div> is valid with unobtrusive javascript

I have a form which loads a div on client side. I have hard coded textbox controls with all validation attributes, similar to what it renders when loaded from server. Inside the div there is submit ...
1
vote
1answer
170 views

MVC3 Managing Remote Validation Exception

i have the following problem: i'm using remote validation for validate a field and now i'm trying to manage exception public class ValidationController : Controller { List<string> values = ...
0
votes
2answers
367 views

MVC 3 - Set non-required field to required at the client side

I'm building an MVC 3 application. Can I set a non-required field to required in the client-side(using JavaScript / jQuery)? I need it to be dynamically when things change in the page. UPDATE: I ...
0
votes
1answer
1k views

Updating div content after submiting ajax form in asp.net MVC3

<div id="myDiv"> <ul class="purpose"> @{ var purpose = CommonMethod.getPurpose(""); for(int i=0;i<10 && i<purpose.Count();i++) { ...
0
votes
3answers
121 views

How to validate properties in 2 different situations in mvc 2 app?

please help me with asp.net MVC 2 application. I have class: public class Account { [Required(....)] [RegularExpression("....")] public string AccountCode{ get; set; } public ...
3
votes
1answer
934 views

MVC 3 Unobtrusive validation of a list

Question I have created a server-side property level validation attribute. But instead of applying it to an individual field I've applied it to a List. This allows me to validate the model as a ...
1
vote
0answers
105 views

MVC validation created on fly is not working in ASPX view and working in Razor

I am having input element and on a button click i am creating a form on fly and placing the input inside the form and define form validation using the following code. ...
1
vote
1answer
619 views

ASP.NET MVC3 Second custom validator method not triggered

I am trying to implement a custom validation on my ASP.NET MVC3 form. The first custom validation is only validating if a file has been selected in the file upload input. It worked fine when I had ...
2
votes
1answer
318 views

How can I return additional (i.e. more than just field=>error message) validation information from custom validation code to the Controller or View?

I am looking for a way to return the following information from my custom validation code: public enum ValidationErrorTypeFlags { Error_Input = 1 << 0, // a "field specific" ...
3
votes
4answers
3k views

Validating File Upload - Jquery and “Accept” attribute

I am using a form to upload a file. I want only PDF files to be uploaded. This is my code: A input box to allow the user to choose a file: @Html.FileBox(m => m.FileName, new { id = "FileName", ...
4
votes
1answer
1k views

Display ModelState error returned by JsonResult in MVC 3 project?

I have a create page that uses a JsonResult action instead of ActionResult. In the ActionResult action, the errors are displayed on the view beside the offending field. Right now the JsonResult only ...
0
votes
1answer
235 views

How to apply validation to a collection item in Asp.net MVC 2

I have a strongly typed view, which hold controls(input boxes) to represent a collection item. So for an example , take case of a view for adding an Employee detail and within that there are variable ...
1
vote
0answers
104 views

Auto generated validators being created for Nullable fields

I have an MVC 3 application which has to be localizable. For my integer MVC is automatically adding Number Validation however I have marked the field as nullable. This is in my ViewModel: public ...
0
votes
2answers
596 views

only show the errormessage when email is invalid

I work in ASP MVC3. I have a model for the input of the contact information of a customer. The information is required. When the viewstat is not valid the textboxes must have a red border (this ...

1 2 3