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

The Archive Base Latest Questions

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

I am using a HTML.ListBox within a view as such: <%= Html.ListBox(projects, Model.Projects) %>

  • 0

I am using a HTML.ListBox within a view as such:

<%= Html.ListBox("projects", Model.Projects)  %>

This is populated with an IEnumerable<SelectListItem> in the model as such:

Projects = project.Select(a => new System.Web.Mvc.SelectListItem
        {
            Value = "foo",
            Text = a.project + "(" + a.count + ")",
            Selected = false
        });

        return Projects;

Which in turn is returned to the controller for passing into a strongly typed view.

My question is, how can I monitor for select item events? I need to be able to perform some action when the user makes a selection and/or de-selection.

Thanks.

  • 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-23T12:18:14+00:00Added an answer on May 23, 2026 at 12:18 pm

    If you’re familiar with jQuery you can trap a change even and submit your FORM:

    $('#projects').change(function () {
        $(this).parents('form').submit();
    });
    

    or you can use ajax to submit some data to an action

    $('#projects').change(function () {
        $.ajax({
            type: 'POST',
            url: '<%=Url.Action("<action>", "<controller>")%>',
                data: { id: $('#projects').val() },
                dataType: 'json',
            complete: function(XMLHttpRequest, textStatus) {
                // Do something here.
                }
            });
    });
    

    UPDATE:

    Since you’re using jQuery Dropdown Check List you can trap the onItemClick even and call an action of your controller passing the value of the selected option and the status checked/non checked :

    $("#projects").dropdownchecklist({
        emptyText: "select something",
        width: 150,
        onItemClick: function(checkbox, selector){
            var isChecked = checkbox.prop("checked");
            alert("element id: " + checkbox.prop("value"));
    
            $.ajax({
            type: 'POST',
            url: '<%=Url.Action("<action>", "<controller>")%>',
                data: { selecteId: checkbox.prop("value"), isChecked: isChecked },
                dataType: 'json',
            complete: function(XMLHttpRequest, textStatus) {
                // Do something here.
                }
            });
       }
    });
    

    You can have a look at this fiddle.

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

Sidebar

Related Questions

@model MedicalVariance.Models.ViewModels.IndividualProfile @Html.ListBox(AdministrationErrorSelected, Model.AdministrationErrorListBox, new { @class = chzn-select }) It look great and
This error message is driving me nuts. I'm getting it when using Html.ListBox and
I'm using @Html.RouteLink(Validate, ValidateEmail, new { email = Model.Email, key = Model.Key }) to
This should be real easy. I am using asmselect plugin for my listbox (Html.Listbox).
how do i insert items into an html listbox from a database? im using
I've 2 asp listbox controls and an html input button, and using js i
I am using HTML Purifier in my PHP project and am having trouble getting
@using(Html.BeginForm()){ Name: @Html.TextBoxFor(o => o.Name) <input type=submit value=submit /> } this gives error CS1002:
Code: (Using HTML Agility Pack) Dim moHtmlParser As HtmlDocument = New HtmlDocument moHtmlParser.LoadHtml(htmlString) Dim
I found this simple tutorial on grouping a listbox: http://joyfulwpf.blogspot.com/2007/06/simple-grouping-in-listbox.html It works perfectly well,

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.