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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:28:39+00:00 2026-05-15T20:28:39+00:00

I have this MVC form with 2 dropdownlist where selection on the first dropdown

  • 0

I have this MVC form with 2 dropdownlist where selection on the first dropdown should update the second one through an AJAX call.

Form looks as follows:

<%using (Ajax.BeginForm("GetChildren", "Home", null, new AjaxOptions { UpdateTargetId = "result" }, new Dictionary<string, object> { { "id", "someForm" } }))
{ %>
<%= Html.DropDownList("masterSelection", new SelectList((IList<Master>)ViewData["Master"], "MasterName", "MasterName"))%>
<span id="result">
    <%Html.RenderPartial("ChildSelection");%>
</span>
<% } %>

With following JQuery script:

$(function () {
    $("#masterSelection").change(function () {
        $("#someForm").submit();
    });
});

This translates to the following client side HTML

<form action="/Home/GetChildren" id="someForm" method="post" onclick="Sys.Mvc.AsyncForm.handleClick(this, new Sys.UI.DomEvent(event));" onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: &#39;result&#39; });">

If I get it right the onsubmit should take care of the AJAX call and also prevent the normal behavior of the form (a full refresh).

Now everything works fine in Firefox but in IE it seems the default behavior is not canceled resulting in an AJAX call (caused by the onsubmit code of the form) and second a full refresh of the page.

Obviously not what I want.

When I debug the onsubmit javascript code it comes down to a method in the MicrosoftAjax.js file which should cancel the default post behavior of my form.

function Sys$UI$DomEvent$preventDefault() {
    /// <summary locid="M:J#Sys.UI.DomEvent.preventDefault" />
    if (arguments.length !== 0) throw Error.parameterCount();
    if (this.rawEvent.preventDefault) {
        this.rawEvent.preventDefault();
    }
    else if (window.event) {
        this.rawEvent.returnValue = false;
    }
}

While debugging with IE I get to the line this.rawEvent.returnValue = false; which should be correct for cancelling an event in IE but apparebtly this is not working for me.

I’ve already worked out a alternate solutions where I use jQuery to fire an AJAX-call and build the new dropdownlist client-side or another where I add an invisible button to the form to call it’s click event in the change event of the first dropdown but I still want to use the first one (cleanest imo).

Any advice?

S.

  • 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-15T20:28:40+00:00Added an answer on May 15, 2026 at 8:28 pm

    I’ve done some more searching and I came up with the following which isn’t as good as simple calling the $("#someForm").submit(); but which I still prefer over building the dropdownlist client side after an AJAX call or calling the click on a hidden button.

    I’ve removed the Ajax.BeginForm from the page.

    <%= Html.DropDownList("masterSelection", new SelectList((IList<Master>)ViewData["Master"], "MasterName", "MasterName"))%>
    <span id="result">
        <%Html.RenderPartial("ChildSelection");%>
    </span>
    

    And use the jquery load method to change the content of my second dropdownlist

        $(function () {
            $("#masterSelection").change(function () {
                $('#result').load("Home/GetChildren", { masterSelection: this.value });
            });
        });
    

    I found this method thanks to the following post:Render partial form in jQuery dialog

    This works for both IE and FF for me.

    I still would like to know why my first code doens’t work in IE.

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

Sidebar

Related Questions

I have an ajax form in asp.net mvc which is as simple as this:
I have an ASP.NET MVC form laid out something like this: @using (Html.BeginForm(null, null,
In my ASP MVC 3 application, I have this form @using (Html.BeginForm()) { <input
I have an ASP.Net MVC page where I want to use AJAX to update
ASP.Net MVC 3 using C# I currently have a form with some dropdown lists
I have a dropdown list in an MVC view. On selection change of dropdown
I have this code in mvc 3 razor @using (Html.BeginForm(MyAction, MyController)) { <input type=text
So I have this nice spiffy MVC-architected application in Java Swing, and now I
I have this markup in an MVC app. <div id=ingredientlistdiv> <% Recipe recipe =
I have this sort of format asp.net MVC View -> Service Layer -> Repository.

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.