Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:23:53+00:00 2026-06-04T01:23:53+00:00

I have a simple MVC website that displays a jquery dialog for editing purposes.

  • 0

I have a simple MVC website that displays a jquery dialog for editing purposes. In this dialog is a textarea that accepts a comma delimited list of skills that the user can enter. Upon submission, my model binder turns this into a List. Here is the code for my model binder

public class EditSkillsModelBinder : DefaultModelBinder
    {
        protected override void OnModelUpdated(ControllerContext controllerContext,
        ModelBindingContext bindingContext)
        {
            var form = controllerContext.HttpContext.Request.Form;
            var skillsAsString = form["SkillsAsString"];
            var user = bindingContext.Model as UserEditDetailsModel;

            //FOR VALIDATION
            ValueProviderResult valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
            ModelState modelState = new ModelState {Value = valueResult};

            if (string.IsNullOrEmpty(skillsAsString))
            {
                bindingContext.ModelState.AddModelError("Skills", "You must enter at least one skill.");
            }
            else
            {
                user.Skills = string.IsNullOrEmpty(skillsAsString) ? new List<string>() : skillsAsString.Split(',').Select(i => i.Trim()).ToList();
            }


        }

    }

And this is the code for my partial view

@using (Ajax.BeginForm("EditUserDetails", new { }, new AjaxOptions { }, new { id = "EditUserDetailsForm" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>UserEditDetailsModel</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>


        <div class="editor-label">
            @Html.LabelFor(model => model.Skills)
        </div>
        <div class="editor-field">
            @Html.TextArea("SkillsAsString", Model.Skills.ToCommaSeparatedString())
            @Html.ValidationMessageFor(model => model.Skills)
        </div>


        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>


}


@*Enable Client Side Validation*@
<script type="text/javascript">
    $(document).ready(function () {
        $.validator.unobtrusive.parse("#content_container > form");
    });
  </script>

All of my simple validations such as [Required] as working on the client side. The model binder validation works as well, however, the error message is not being displayed. I am assuming that I am missing something in the javascript to register the error but I cant figure out what it is. Any help would be appreciated. Thanks.

Here is a screenshot of the problem

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:23:54+00:00Added an answer on June 4, 2026 at 1:23 am

    So I ditched the unobtrusive and what I found was that I had a [Required] attribute on my model for skills which was causing the validation in the screenshot, not the validation from my model binder.

    Although model binders are not intended for validation, it appears that trying to mix validation attributes and model binders for the same model property will cause problems (at least in my case of trying to convert a string to list), therefore, I am validating strictly in my model binder (which provides additional functionality) and it has started working.

    EDIT

    I should add that I dropped validation attributes in favor of FluentValidation per this post. It is much less verbose, integrates with client validation, and is easier to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a simple mechanism for my mvc website to pull in html
I have a simple MVC 4 (Beta) Application and just observed something that I
I have a very simple MVC site that is returning a 404 not found
I have an ajax form in asp.net mvc which is as simple as this:
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
I'm sure this is a simple issue, but I have noticed that when I
So I have an MVC app that should change the Website title, and header
I have started converting my simple website to ASP.NET MVC, just to mess around
I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which
Have a simple Spring MVC portlet, and from one of portal pages I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.