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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:51:13+00:00 2026-05-23T13:51:13+00:00

I have a drop down list that I need to react to asynchronously. I

  • 0

I have a drop down list that I need to react to asynchronously. I cannot get the Ajax.BeginForm to actually do an asynchronous postback, it only does a full postback.

               using (Ajax.BeginForm("EditStatus", new AjaxOptions { UpdateTargetId = "divSuccess"}))
            {%>
                <%=Html.DropDownList(
                    "ddlStatus",
                    Model.PartStatusList.OrderBy(wc => wc.SortOrder).Select(
                        wc => new SelectListItem
                                  {
                                      Text = wc.StatusDescription,
                                      Value = wc.PartStatusId.ToString(),
                                      Selected = wc.PartStatusId == Model.PartStatusId
                                  }),
                                                                                            new { @class = "input-box", onchange = "this.form.submit();" }
                                      )%>
                <div id='divSuccess'></div>
        <%
            }

When the user selects an item from the list, it does a full postback and the controller method’s return value is the only output on the screen. I am expecting the controller method’s return value to be displayed in “divSuccess”.

        [AjaxAwareAuthorize(Roles = "Supplier_Administrator, Supplier_User")]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult EditStatus(PartPropertiesViewModel partPropertiesViewModel)
    {
        var part = _repository.GetPart(partPropertiesViewModel.PartId);
        part.PartStatusId = Convert.ToInt32(Request.Form["ddlStatus"]);

        _repository.SavePart(part);

        return Content("Successfully Updated Status.");
    }
  • 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-23T13:51:14+00:00Added an answer on May 23, 2026 at 1:51 pm

    How about doing this the proper way using jQuery unobtrusively and getting rid of those Ajax.* helpers?

    The first step is to use real view models and avoid the tag soup in your views. Views should not order data or whatever. It’s not their responsibility. Views are there to display data that is being sent to them under the form of a view model from the controller. When I see this OrderBy in your view it’s just making me sick. So define a clean view model and do the ordering in your controller so that in your view you simply have:

    <% using (Html.BeginForm("EditStatus", "SomeControllerName", FormMethod.Post, new { id = "myForm" }) { %>
        <%= Html.DropDownListFor(
            x => x.Status,
            Model.OrderedStatuses,
            new {
                @class = "input-box",
                id = "myDDL"
            }
        ) %>
    <% } %>
    
    <div id="divSuccess"></div>
    

    and finally in a completely separate javascript file subscribe for the change event od this DDL and update the div:

    $(function() {
        $('#myDDL').change(function() {
            var url = $('#myForm').attr('action');
            var status = $(this).val();
            $.post(url, { ddlStatus: status }, function(result) {
                $('#divSuccess').html(result);
            });
        });
    });
    

    This assumes that in your controller action you would read the current status like this:

    [AjaxAwareAuthorize(Roles = "Supplier_Administrator, Supplier_User")]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult EditStatus(PartPropertiesViewModel partPropertiesViewModel, string ddlStatus)
    {
        var part = _repository.GetPart(partPropertiesViewModel.PartId);
        part.PartStatusId = Convert.ToInt32(ddlStatus);
        _repository.SavePart(part);
        return Content("Successfully Updated Status.");
    }
    

    And when you see this you might ask yourself whether you really need a form in this case and what’s its purpose where you could simply have a dropdownlist:

    <%= Html.DropDownListFor(
        x => x.Status,
        Model.OrderedStatuses,
        new Dictionary<string, object> {
            { "class", "input-box" },
            { "data-url", Url.Action("EditStatus", "SomeControllerName") },
            { "id", "myDDL" }
        }
    ) %>
    <div id="divSuccess"></div>
    

    and then simply:

    $(function() {
        $('#myDDL').change(function() {
            var url = $(this).data('url');
            var status = $(this).val();
            $.post(url, { ddlStatus: status }, function(result) {
                $('#divSuccess').html(result);
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop down list that has options that need to be passed
I have about 10 drop down list controls that get populated. Instead of copying/pasting
I have a drop down list that triggers an updatepanel when the index is
I'm using classic asp, I have a drop down list that the user selects
I have written a cascading drop down list using JQuery. The code that I
I have a small little problem. I am have a drop down list that
Ok so I have drop down list connected to a datasource, and I need
Lets say that I have a drop down list that I want to create
I have an internal application that I needs to have a drop down list
I have a drop down list displaying values in a select tag that I

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.