0
選択したプラグインをMultiSelectListに使用しようとしていますが、ビューにプラグインが表示されていても問題があります。なぜあなたはそれを理解できますか?jquery Asp.netで選択したプラグインMVC 4がビューに表示されない
ビュー:
@model test.Models.Employee
....
<script src="~/Scripts/chosen.jquery.min.js"></script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<link href="~/Content/chosen.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
$('.chzn-select').chosen();
});
</script>
@using (Html.BeginForm())
{
@Html.LabelFor(model => model.Name)
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
@Html.LabelFor(model => model.Services)
@Html.ListBoxFor(model => model.Services, ViewBag.serviceList as MultiSelectList,
new { @class = "chzn-select", id="service", data_placeholder = "Choose Services..." })
@Html.ValidationMessageFor(model => model.Services)
<input type="submit" value="Create" class="btn btn-default" />
}
<script>
$(".chzn-select").chosen();
</script>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
そして、私は適切にユーザーがフォームを送信する場合、サービスフィールドからのデータを結合し、MySQLのテーブルにそれを保存したい場合は、私はpublic IEnumerable>string> Services { get; set; }
にpublic string Services { get; set; }
のための私のモデルを修正する必要がありますか? IEnumerable
を使用して移行したときに、Services
の列が表示されず、サービスデータの保存について心配しています。
モデル:
public class Employee
{
[Key]
public string EmpId { get; set; }
public string Name { get; set; }
public string Services { get; set; }
}
My Jqueryの行には何らかの理由で幅も含める必要がありましたが、この回答は大変感謝しています。 $( '.chzn-select')。選択された({幅: "95%"}); – adudley