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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:12:45+00:00 2026-05-18T05:12:45+00:00

I am trying to use Ajax to allow a user to save information (display

  • 0

I am trying to use Ajax to allow a user to save information (display a save notification which then fades out) or to submit (redirect to a “your form has been submitted” page). In both cases, I require error checking (which I have done via Html.EnableClientValidation(). and it is working properly).

Currently, my form looks like this…

<% using (Ajax.BeginForm("Index", "Scenario", new AjaxOptions { 
   HttpMethod = "Post", OnBegin = "scenarioCheckForErrors", 
   OnSuccess = "scenarioSubmitSuccess" }, new { id = "scenarioForm" }))
{ %>
  <!-- My form goes here. -->
  <div class="submitButtons">
    <input type="submit" value="Save" name="submitButton" />
    <input type="submit" value="Submit" name="submitButton" />
  </div>
} %>

All the scenarioCheckForErrors does is changes some imagery if errors have been found during validation. scenarioSubmitSuccess is displaying the save notification.

Between all that, I am using my controller to actually handle the saving of the data and doing all that kind of “stuff.” Here is part of the method:

[HttpPost]
[Header("Setup Scenario")]
public ActionResult Index(string submitButton) {
  // Determine whether to just save or to save and submit.
  switch (submitButton)
  {
      case "Save":
          return Save(scenario);
      case "Submit":
          return Submit(scenario);
      default:
          // Should never be reached.
          return View();
  }
}

And the Save and the Submit methods…

/// <summary>
/// Save a the scenario.
/// </summary>
/// <param name="scenario"></param>
/// <returns></returns>
private ActionResult Save(Scenario scenario)
{
    if (ModelState.IsValid && TryUpdateModel(scenario, "Scenario"))
    {
        // Save the scenario.
    }

    return View(scenario);
}

/// <summary>
/// Submit the scenario.
/// </summary>
/// <param name="scenario"></param>
/// <returns></returns>
private ActionResult Submit(Scenario scenario)
{
    if (TryUpdateModel(scenario, "SaveScenario"))
    {
        // Call Save() method, and then...
        return Redirect("/Scenario/Done");
    }

    return View(scenario);
}

I am struggling with how to get the redirect to happen to the “Done” page, but to still allow the “You have successfully saved…” dialog to pop-up when the user saves. What am I not doing correctly?

  • 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-18T05:12:45+00:00Added an answer on May 18, 2026 at 5:12 am

    Instead of redirecting from the view, you could redirect using javascript after you have shown “You have successfully saved”.

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

Sidebar

Related Questions

I am trying to display contact information and allow edit in place. It is
I'm trying to use the JQuery UI Sortable plugin to allow a user to
I am currently trying to use AJAX in my application via jRails. I am
I am trying to use .ajax() to post a People object to a MVC2
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I am trying to use periodic refresh(ajax)/polling on my site by XMLHttp(XHR) to check
I am trying to use the Bing Maps Ajax Control to plot pins of
I am trying to make use of jQueryUI AJAX tabs in my ASP.Net Webforms
I'm trying to use html5 validation and ajax. The method checkValidity doesn't solve my
I am trying to use jQuery.one on ajax loaded element. It is working if

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.