html.listboxfor

Checkbox to enable or disable a list box

你。 提交于 2021-01-28 05:49:18
问题 I have a checkbox on my ASP.NET MVC page that I create like: <div> @Html.CheckBoxFor(m => m.allUsers, new { Name = "allUsersCheck" }) @Html.LabelFor(m => m.allUsers) </div> I also have a listbox that I create with: @Html.ListBoxFor(x => x.selectedUsers, Model.ListofUsers, new { style = "width:200px", size = 10, Id = "lbUsers" }) I have this following script (which I wrote to disable the listbox when my checkbox is checked. I can't understand why it doesn’t work. Can someone point out what's

Model with collection - Html.ListBoxFor doesn't set selected items

試著忘記壹切 提交于 2019-12-08 08:34:41
问题 This one is driving me crazy and before I loose my sane please help. Summary of the issue: My model "Thread" has collection of "ForumMessage", each ForumMessage has one Multi select drop down list. All I want to do is set the selected value based on values coming from Database. I have gone thru many threads but wasn't able to find the solution. In case if you are aware of any such question please let me know and I will go thru them. Below are my models public class Thread { public List

Model with collection - Html.ListBoxFor doesn't set selected items

萝らか妹 提交于 2019-12-07 04:48:27
This one is driving me crazy and before I loose my sane please help. Summary of the issue: My model "Thread" has collection of "ForumMessage", each ForumMessage has one Multi select drop down list. All I want to do is set the selected value based on values coming from Database. I have gone thru many threads but wasn't able to find the solution. In case if you are aware of any such question please let me know and I will go thru them. Below are my models public class Thread { public List<ForumMessage> Messages { get; set; } //Master list coming from DB public List<Classifications>

MVC Method to output unordered list from the ListBoxFor method

隐身守侯 提交于 2019-12-02 06:52:25
问题 In MVC3, I want to change the HTML output by the Html.ListBoxFor method so that instead of an HTML list box with all the available values (and the selected values highlighted), I want to simply output an unordered list (UL, LI) of the selected items and not a SELECT element. The issue is that I want to keep exactly the same method signature as the ListBoxFor method , accepting a MultiSelectList object and a List which is the selected values. I then want the unordered list to only output the

How do you properly create a MultiSelect <select> using the DropdownList helper?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 19:20:50
(sorry, there are several item here but none seems to allow me to get this working.) I want to create a DropDownList which allows multiple selection. I am able to populate the list but I can't get the currently selected values to seem to work. I have the following in my controller: ViewBag.PropertyGroups = from g in db.eFinGroups where g.GroupType.Contents == "P" select new { Key = g.Key, Value = g.Description, Selected = true }; ViewBag.SelectedPropertyGroups = from g in company.Entities .First().Properties.First().PropertyGroups select new { g.eFinGroup.Key, Value = g.eFinGroup.Description }

How do you properly create a MultiSelect <select> using the DropdownList helper?

南笙酒味 提交于 2019-11-26 19:50:29
问题 (sorry, there are several item here but none seems to allow me to get this working.) I want to create a DropDownList which allows multiple selection. I am able to populate the list but I can't get the currently selected values to seem to work. I have the following in my controller: ViewBag.PropertyGroups = from g in db.eFinGroups where g.GroupType.Contents == "P" select new { Key = g.Key, Value = g.Description, Selected = true }; ViewBag.SelectedPropertyGroups = from g in company.Entities