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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:04:45+00:00 2026-05-23T17:04:45+00:00

I have the following scenario in MVC2 /VS 2008: A user form with 2

  • 0

I have the following scenario in MVC2 /VS 2008:

A user form with 2 submit buttons, a textbox and a dropdownlistbox. Users enter all or part of a buyers name and press the ‘find’ submit button. The ‘find’ button triggers a jquery post which refreshes the contents of the dropdownlistbox according to the text entered. The dropdown list box is contained within a div on another .aspx page. That is the jquery post updates a div each time the ‘find’ button is submitted.

To prevent the ‘find’ button from reloading the page I have used preventDefault. So far so good. Now when I try to use the ‘AddMapping’ submit button to post the form it won’t post because of the preventdefault setting. If I toggle this setting I can trigger a get, but not a post. In any case it triggers a default (index) view reload instead of the AddMapping controller (post) action it’s intended for.

In the form I have these buttons:

<input type="submit" name="Find" value="Find" onclick="return confirmFind()">
<input type="submit" name="AddMapping" value="AddMapping">

The JQuery is like so:

<script language="javascript" type="text/javascript">
// refresh the div(dropdownbox)
function Refresh() {
    var dataPost = { name: $("#Buyer").val() };
    $.ajax({
        type: "POST",
        url: "/MTZ/Mapping/RefreshDropDown",
        data: dataPost,
        success: function(msg) {
            $("#ddlRefresh").empty();
            $("#ddlRefresh").append(msg);
        },
        error: function(msg) {
            alert("function failed: " + msg);
            debugger;
        }
    });
}
function confirmFind() {
    alert("find");
    $("form").submit(function(e) {
        { Refresh(); }
        e.preventDefault(); // prevent the reload from occurring
    });
}     

The AddMapping submit is intended for this controller/action:

[AcceptVerbs(HttpVerbs.Post)]
[HttpPost]
[AcceptParameter(Name = "AddMapping", Value = "AddMapping")]
public ActionResult Index(MappingModel modelpassed)

What I’d like to be able to do is find a way of posting the ‘AddMapping’ submit button whilst having the ‘find’ button continuing to only trigger the action included in the javascript/jquery function i.e no reloading of the view.

Is this possible or do I need to try a different approach here?

  • 1 1 Answer
  • 1 View
  • 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-23T17:04:46+00:00Added an answer on May 23, 2026 at 5:04 pm

    The easy answer is that if your submit button’s onClick event returns false, it won’t actually submit anything, so you should just need to have your “find” button return false and your real submit button not.

    However, you might find it more clear to split the two submit buttons into two forms. I do this a lot with MVC3 because of the new unobtrusive AJAX features that let me do things like this:

    @using ( this.Ajax.BeginForm("RefreshDropDown", "Mapping", new AjaxOptions
    {
        HttpMethod = "POST",
        InsertionMode = InsertionMode.Replace,
        UpdateTargetId = "ddlRefresh",
        OnComplete = "confirmFind"
    }) )
    {
        <input type="submit" name="Find" value="Find" />
    }
    
    @using ( this.Html.BeginForm("Index", "Home") )
    {
        <input type="submit" name="AddMapping" value="AddMapping">
    }
    

    You should be able to make your view visually appear to be a single unit even though, behind the scenes, you have separate forms. The only trick is making sure you have all the correct input fields in the correct forms to be bound to your models on submit.

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

Sidebar

Related Questions

I have the following scenario: in activity A, when a user clicks a button,
I have the following scenario: User X logs in to the application from location
I have the following scenario. A cube created in SSAS 2008. I can connected
Have the following scenario. I have a few form, which essentially have a few
I have the following scenario to emulate in jMeter: 100 users logging in once
I have the following scenario: A user shelves some changes. Time goes by and
I have the following scenario: My page has a dropdown list that allows user
I have the following scenario I have a main form as MDI parent and
I have the following scenario, a user on domain1.com opens a new window on
I have the following scenario: User->HABTM->businesses Suppliers->HABTM->businesses Suppliers->HAS_MANY->Payments I am having real trouble working

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.