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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:46:43+00:00 2026-06-01T02:46:43+00:00

I have a jquery modal dialog that displays a partial view. The partial view

  • 0

I have a jquery modal dialog that displays a partial view. The partial view contains a form which posts back to see if the entered value is valid. What I want is the error message that I return in the controller to be displayed on the partial view without refreshing the page. How do I do this ajaxically?

Partial View:

    @model SimpleSalon.Data.Models.GiftCard

    @using (Html.BeginForm("AddGiftCard", "Sales", FormMethod.Post, new { @class="addGiftCardForm" }))
    {
        @Html.ValidationSummary("Correct the errors below:")

        <table>
            <tr>
                <td>Card Number</td>
                <td>@Html.TextBoxFor(x => x.CardNumber)</td>
            </tr>
            <tr>
                <td>Amount</td>
                <td>@Html.TextBoxFor(x => x.InitialBalance)</td>
            </tr>
        </table>
    }

Controller:

    [HttpPost]
    public ActionResult AddGiftCard(GiftCard model)
    {
        if (ModelState.IsValid)
        {
            //if it's valid in the db continue on
            //else ModelState.AddModelError("", "card number not valid.")
        }

        return View(model);
    }

Thanks in advance!

  • 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-01T02:46:45+00:00Added an answer on June 1, 2026 at 2:46 am

    You could use an Ajax.BeginForm instead of Html.BeginForm:

    @using (Ajax.BeginForm("AddGiftCard", "Sales", null, new AjaxOptions { UpdateTargetId = "container" }, new { @class="addGiftCardForm" }))
    {
        ...
    }
    

    Notice that I have used UpdateTargetId = "container" in the AjaxOptions. This means that the partial result returned by the AddGiftCard action will be injected into a DOM element with id="container". So make sure you put such element to wrap the partial in the jQuery dialog.

    Also for this to work make sure you have referenced the jquery.unobtrusive-ajax.js script to your page:

    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML link that opens a jQuery modal dialog which contains an
I have a jQuery dialog that posts a form when the Please Confirm button
I have a modal dialog plugin written in jquery, that binds to the click
I have a jQuery Model windows which contains a form. On creating of the
I have a jQuery modal dialog with an iFrame in it that shows some
I have a textarea element inside of a jquery modal dialog that has an
On my web page I have a button that opens a modal jQuery dialog.
I have the following link which opens a jquery modal window: <div id='confirm-dialog'><a href='#'
I have a problem with Jquery UI modal dialogs. I have modal dialog (dialogA),
Ok, I am new to JQuery, I have a modal that has a asp:Literal

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.