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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:51:57+00:00 2026-05-26T17:51:57+00:00

On my view, I have 2 partial views. 1st partial view (PV1) : user

  • 0

On my view, I have 2 partial views.

  • 1st partial view (PV1): user can type an item in a textbox and submit through an ajax form.
  • 2nd partial view (PV2): user can see a list of items previously submitted.

The PV1 uses UpdateTargetId on a div on the PV2 because we would like to update our list with the newly added item.

Everything works well when items submitted on the PV1 are valid. It doesn’t work when ModelState.IsValid == false when ajax form is submitted. It doesn’t work because the UpdateTargetId is located on the PV2, and I need to update the PV1 for showing the ModelState Errors. So we encounter with duplicate of the PV1 on the PV2!

Below is another stackoverflow post on a similar problem but no solutions has been provided.

ASP.NET MVC AJAX change UpdateTargetId if ModelState is invalid

I think a Json alternative may be a solution but I’m wondering if we can adapt the standard Ajax form method to suit our need 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-05-26T17:51:58+00:00Added an answer on May 26, 2026 at 5:51 pm

    Instead of using UpdateTargetId, you could try using OnComplete:

    @using (Ajax.BeginForm(new AjaxOptions { OnComplete = "complete" }))
    {
        ...
    }
    

    and inside this handler test whether there is an error in the resulting view:

    function complete(result) {
        var isError = $('span.field-validation-error', result.responseText).length > 0;
        if (isError) {
            // there was an error => we update the container of the form
            $('#frmContainer').html(result.responseText);
        } else {
            // no error => we hide validation errors and update the result container
            $('#frm .field-validation-error').hide();
            $('#frm .input-validation-error').removeClass('input-validation-error');
            $('#result').html(result.responseText);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in a partial view I have the following: <%Html.RenderAction(MVC.User.GetComments(Model.UserGroupName)); %> can I render a
How can I have a view render a partial (user control) from a different
I'm using MVC2 with VS2010 I have a view that has two partial views
I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
if i have created a view model and have a partial form that is
On some View page I have two partial views (their html is the same).
I have a Partial view (Login, with username, password and Submit button), and the
I have a partial view where I render, if the user has choosen an
I have a view with multiple forms on it. These forms have partial views
I have partial view that displays model-specific flash messages. The partial looks like: app/views/mymodel/_flashpartial.erb

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.