0

Am having a listbox in MVC using HTML helpers

 @Html.ListBoxFor(d => d.SelectedItems, new MultiSelectList(Model.Items, "Value", "Text"), new { id = "listID", name = "listName"})

But the above code didnt change the name of listbox but id changed am getting name as SelectedItems.

is that the correct way ? what am doing wrong ?

Thanks

4

2 回答 2

0

将属性添加到您拥有 SelectedItems 列的班级

[DisplayName("listName")]
public string Name { get; set; }
于 2013-08-14T09:29:15.710 回答
0

您可以尝试使用此助手:

@Html.ListBox("listName", new MultiSelectList(Model.Items, "Value", "Text"), new { id = "listID"})
于 2013-08-14T09:30:17.327 回答