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 8717027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:13:13+00:00 2026-06-13T06:13:13+00:00

I have a partial view with a DropDownList control and a textbox. When nothing

  • 0

I have a partial view with a DropDownList control and a textbox.

When nothing is selected or no text is entered the ModelState.IsValid is FALSE

BUT I can see no validation errors displayed annotated on my properties.

Why is that? I can see in the ModelState.Value.Errors property there is an “Name is

missing” for example.

When I confirm the invalid view I see this in my output window:

A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll


public ActionResult Edit()
{
    return LoadEditTemplates();
}


[HttpPost]
public ActionResult Update(EditTemplateListViewModel viewModel)
{
    if (ModelState.IsValid && !_templateDataProvider.TemplateExists(viewModel.Name))
    {
        Template template = Mapper.Map<EditTemplateListViewModel, Template>(viewModel);
        _templateDataProvider.UpdateTemplate(template);
        return new JsonNetResult(new { success = true });
    }

    return PartialView(viewModel);
}

private ActionResult LoadEditTemplates()
{
    var templates = _templateDataProvider.GetTemplates();
    EditTemplateListViewModel editTemplateViewModel = new EditTemplateListViewModel()
    {
        DisplayList = Mapper.Map<IEnumerable<Template>, IEnumerable<TemplateViewModel>>(templates),
    };
    return PartialView(editTemplateViewModel);
}

public class EditTemplateListViewModel
    {
        [Required(ErrorMessage = "No template selected.")]
        public int TemplateId { get; set; }

        [Required(ErrorMessage="Name is missing")]
        public string Name { get; set; }

        public IEnumerable<TemplateViewModel> DisplayList { get; set; }      
    }

@model ITMS.Web.Models.EditTemplateListViewModel

@*Remote Validation*@
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm("Update", "Template"))
{       
    @Html.ValidationSummary(false)
    @Html.DropDownListFor(x => x.TemplateId, new SelectList(Model.DisplayList, "TemplateId", "Name"), new { @class = "listviewmodel" })

    <p class="editor-label">@Html.LabelFor(model => model.Name)</p>
    <p class="editor-field">@Html.EditorFor(model => model.Name)</p>
    <p class="editor-field">@Html.ValidationMessageFor(model => model.Name)</p>   
}
  • 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-13T06:13:14+00:00Added an answer on June 13, 2026 at 6:13 am

    When I returned the data from the post action I realized the Argument cast exception because I did not pass data for example to the SelectItem list “DisplayList”. It was null and thus bang…

    I just filled the missing data to redisplay the view and the errors are visible 🙂 heck… I already stepped in that failure once…

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

Sidebar

Related Questions

I have a partial view which contain JavaScript and Ajax, but does not run
I have created a partial view that displays a dropdownlist html.DropDownListFor(m => m.SelectOption, Model.SelectOption)
I have two partial view and I want to call one of them in
I have a partial view of a row for the table. Each row in
I have a partial view which is displayed on the top right of every
I have a partial view that I want to basically take care of itself
I have a partial view that is shared between two controllers and I'm trying
I have a partial view (UserControl) that implements a simple pager in my Asp.Net
I have a partial view that I have created called noteEditor. That is rendered
I have a partial view the returns an HTML5 video tag. I want to

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.