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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:09:15+00:00 2026-05-25T12:09:15+00:00

I have a partial view in my MVC3/Razor app for paging a grid which

  • 0

I have a partial view in my MVC3/Razor app for paging a grid which works fairly well currently. When I AJAXified it, I converted all the @Html.ActionLink calls to @Ajax.ActionLink. Now I want to add a DropDownList, but @Html.DropDownList doesn’t cause the AJAX section to post back, and there’s no @Ajax.DropDownList.

What can I do to get this dropdown to post back on change?

Edit: By preference, something that I can write into my own @Ajax.DropDownList helper would be best. I’m sure the jQuery-based solutions below work, and I’ll use them if necessary, but I’m sure I’m going to want this functionality elsewhere, and I’d prefer to not have all these little scripts floating around.

  • 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-25T12:09:16+00:00Added an answer on May 25, 2026 at 12:09 pm

    Here’s what I came up with – it was originally inspired by Darin’s answer, but I took it in a completely different direction.

        public static MvcHtmlString DropDownList(this AjaxHelper html, string action, RouteValueDictionary routeValues, AjaxOptions options, IEnumerable<SelectListItem> selectItems, IDictionary<string, object> listHtmlAttributes)
        {
            var url = new UrlHelper(html.ViewContext.RequestContext);
    
            // Wrap it in a form
            var formBuilder = new TagBuilder("form");
    
    
            //  build the <select> tag
            var listBuilder = new TagBuilder("select");
            if (listHtmlAttributes != null && listHtmlAttributes.Count > 0) listBuilder.MergeAttributes(listHtmlAttributes);
            StringBuilder optionHTML = new StringBuilder();
            foreach (SelectListItem item in selectItems)
            {
                var optionBuilder = new TagBuilder("option");
                optionBuilder.MergeAttribute("value", item.Value);
                optionBuilder.InnerHtml = item.Text;
                if (item.Selected)
                {
                    optionBuilder.MergeAttribute("selected", "selected");
                }
    
                //optionBuilder.Attributes["onchange"] = "($this.form).attr('action', '" + url.Action(action, routeValues).Replace("___", item.Value) + "');$(this.form).submit();";
                optionHTML.Append(optionBuilder.ToString());
            }
            listBuilder.InnerHtml = optionHTML.ToString();
            listBuilder.Attributes["onchange"] = "$(this.form).attr('action', '" + url.Action(action, routeValues).Replace("___", "' + $(this).first('option:selected').val() + '") + "');$(this.form).submit();";
            formBuilder.InnerHtml = listBuilder.ToString();
    
            foreach (var ajaxOption in options.ToUnobtrusiveHtmlAttributes())
                formBuilder.MergeAttribute(ajaxOption.Key, ajaxOption.Value.ToString());
            string formHtml = formBuilder.ToString(TagRenderMode.Normal);
    
            return MvcHtmlString.Create(formHtml);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

'm using ASP.NET MVC 3 with Razor views. I have a partial view which
Using MVC3 Razor, I have a partial view with some text, two text boxes
Using asp.net MVC3, I have a partial view which requires remote validation. As I
How can I pass parameters to a partial view in MVC3 (razor). I replaced
I have a partial view/user control called LogOnUserControl which I display in a side
I have an MVC3 web app to which I want to start using whole
I have an MVC3 application with Razor and I created a View that inside
I have a simple PartialView setup in my MVC3 Project using the Razor View
I have a partial view that I want to basically take care of itself
I have a partial view that is shared between two controllers and I'm trying

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.