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

  • Home
  • SEARCH
  • 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 7784015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:00:56+00:00 2026-06-01T20:00:56+00:00

This validation should work, but the post fires right past it if there are

  • 0

This validation should work, but the post fires right past it if there are no selected values in the dropdown. When moved to another non-partial the validation works just fine. Edited for brevity.

ViewModel:

public class BuilderVM
{
    [Display(Name = "Select A Task")]
    [Required]
    public int? TaskId { get; set; }
    public GenericSelectList Tasks { get; set; }
}

Parent View (the partial view is rendered at the bottom of this page after a post. as you may have noticed, the ajax options dictate that the partial view will be rendered in div id="MoveOn"):

@{
 ViewBag.Title = "Builder";
 AjaxOptions ajaxOpts = new AjaxOptions
 {
    LoadingElementDuration = 2,
    LoadingElementId = "removeChoice",
    UpdateTargetId = "MoveOn"
 };
}
<div id="removeChoice">
@using (Ajax.BeginForm("Selected", ajaxOpts))
{
<fieldset>
    <div>
     //Data For Submission (This data validates perfectly before post)
    </div>
    <p><input type="submit" value="Go" /></p>
</fieldset>
}
</div>
<div id="MoveOn"></div>

Partial View (rendered after a post from parent view):

@model namespace.BuilderVM
@{
 AjaxOptions ajaxOpts = new AjaxOptions
  {
    UpdateTargetId = "Entry",
    LoadingElementDuration = 2,
    LoadingElementId = "RemoveEntry"
  };
}

<div id="RemoveEntry">
<h2>Details</h2>
@using (Ajax.BeginForm("Data", ajaxOpts))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Data</legend>
<div>
    <span class="label">@Html.LabelFor(model => model.TaskId)</span>
    <span class="content">
    @Html.DropDownListFor(
        model => model.TaskId,
        new SelectList(
            Model.Tasks.Values,
            "Id",
            "DisplayFields",
            Model.Tasks.StartValue
        ),
        Model.Tasks.Message
    )
    </span>@Html.ValidationMessageFor(model => model.TaskId)
</div>
<p><input type="submit" value="Add Work Completed Data" /></p>
</fieldset>
}
</div>
<div id="Entry"></div>

Although the dropdownlistfor is bound to model.TaskId which is annotated with [Required] when the post button is clicked (input type="submit") and there is no value selected in the dropdownlist the post goes through instead of stopping and appending the validation message. I am not sure what to do to fix this, as it works just fine when copy pasted to a regular view. Why wont the partial view validation work?

  • 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-01T20:00:57+00:00Added an answer on June 1, 2026 at 8:00 pm

    The problem is that the validator just loads in the beginning (with $(document).ready()).
    What you can do is the following (insert in the partial view):

        <script>
            $(function() {
                $.validator.unobtrusive.parse('.Content');
            });
        </script>
    

    From the given information I assume this is your problem. Hope this helps you.

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

Sidebar

Related Questions

How can I force validation when user clicks button? One would think this should
This is the validation in my InfoModel. I want to validate birthday but the
After doing some research I feel this should work, however it is not saving
I've read David Hayden's great post on MVC 3 Remote validation . However there
I have been trying to figure out how all this validation works, but I
I have this validation validates :contact_id, :presence => true, :uniqueness => {:message => 'has
Please have a look at this validation array in my cakephp app for model
I want to create a validation range in cell A1. This validation allow user
For example I have a css style like this : input.validation-passed {border: 1px solid
Although I have my php validation doing this, thought I may as well pop

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.