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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:16:32+00:00 2026-05-31T08:16:32+00:00

I am trying to use Jquery Multiselect plugin from Beautiful site and MVC3 together

  • 0

I am trying to use Jquery Multiselect plugin from Beautiful site and MVC3 together to send values to server. As shown in example from Darin the key is to create MultiSelectModelBinder class that will, I guess, recognize values send from client, because the multiselect plugin uses the [] notation to send the selected values to the server. My aproach is a little diferent, i fill dropDownList from my controller and not the model, keeping the model clean, and also been able to fill the list from Database. I used Darins example to create MultiSelectModelBinder and register it,in the model binder in Application_Start(). My problem is that I always keep getting empty Model back to my controller, here is the code:

MODEL:

public class PersonsSearchModel
{
    public string Person { get; set; }
    public string Company { get; set; }

    //here is my Cities collection
    public IEnumerable<string> Cities { get; set; }
} 

VIEW:

@model MyNamespace.Model.PersonsSearchModel
@using (Ajax.BeginForm("Search", "Persons", new AjaxOptions
{
    HttpMethod = "GET",
    InsertionMode = InsertionMode.Replace,
    UpdateTargetId = "results",
    LoadingElementId = "progress"
},
    new { @id = "searchFormPerson" }
))
{    
  <span>
      @Html.TextBoxFor(x => Model.Person, new { @class = "halfWidth"})
  </span> 
  <span>
      @Html.TextBoxFor(x => Model.Company, new { @class = "halfWidth"})
  </span> 
  <span>
      @Html.ListBoxFor(x => x.Cities, Model.Items, new { @id="combobox1"})
  </span>
  <input name="Search" type="submit" class="searchSubmit" value="submit" />
}

CONTROLLER:

public ActionResult Index()
{

    var listCities = new List<SelectListItem>();
    listCities.Add(new SelectListItem() { Text = "Select one...", Value = "" });
    listCities.Add(new SelectListItem() { Text = "New York", Value = "New York" });
    listCities.Add(new SelectListItem() { Text = "Boston", Value = "Boston" });
    listCities.Add(new SelectListItem() { Text = "Miami", Value = "Miami" });
    listCities.Add(new SelectListItem() { Text = "London", Value = "London" });

    ViewBag.Cities = listCities;

    return View();

}

public class MultiSelectModelBinder : DefaultModelBinder
{
    public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
        var model = (PersonsSearchModel)base.BindModel(controllerContext, bindingContext);
        var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName + "[]");
        if (value != null)
        {
            return value.RawValue;
        }
        return model;

    }
}

Here the data from client sholud arive, butt is always null?

public PartialViewResult Search(PersonsSearchModel psm)
{
     var person = psm.Person;
     var company = psm.Company;
     var city =  psm.Cities.ElementAt(0);

     return GetResultPartialView(city);

}

GLOBAL.asax.cs

 protected void Application_Start()
 {
     //...
    //model binder

     ModelBinders.Binders.Add(typeof(IEnumerable<string>), new
     FinessenceWeb.Controllers.PersonsController.MultiSelectModelBinder());
 }

JQUERY

$("#combobox1").multiSelect();
  • 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-31T08:16:33+00:00Added an answer on May 31, 2026 at 8:16 am

    Well… After looking into DOM, and Jquery plugin, turns out the plugin gives the select element, atribute name, current id, so they are the same, and the form, well.. look’s at the name attr. So solution wolud be:

    $("#Cities").multiSelect();
    

    Cheers!

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

Sidebar

Related Questions

I'm trying to use jquery tabs, i got the code from the site: http://docs.jquery.com/UI/Tabs
I'm trying to use jQuery's $.post() method with variables from values taken from textboxes
i'm trying to use jQuery multiselect plugin in a form editing jqGrid (add form).
I am trying to use jQuery's ajax functionality to update data from a web
I'm trying to use jQuery to get data from an ASP.NET web service (SharePoint
I'm trying to use jQuery.scrollTo plugin with accordion (where one block expands after clicking
I am trying to use jquery autocomplete plugin, I want it to suggest ItemCodes
Trying to use JQuery Easing plugin in my wordpress but its giving me following
I'm trying to use jQuery with the Validate plugin, except I cannot get my
I am trying to use jQuery.parseJSON to parse out the return value from an

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.