在MVC中的bootbox对话框中使用Kendo Multiselect下拉列表时出错

问题描述 投票:0回答:1

我试图在MVC的bootbox对话框中使用MultiSelect下拉列表,但它不适合我。我已经尝试将以下代码放在bootbox.dialog的消息中

@(Html.Kendo().MultiSelect().Name("userRoles").DataTextField("RoleName").DataValueField("RoleID").Enable(true).BindTo(new SelectList(ViewBag.Roles, "RoleID", "RoleName")))

我知道对于multiselect下拉列表,以下代码将工作,但我需要使用kendo multiselect,我注意到在bootbox对话框之外它正在工作但是在内部使用时出错

@Html.ListBox("userRoles", new SelectList(ViewBag.Roles, "RoleID", "RoleName"), new { @class = "form-control" })

它不会给出任何编译时错误。错误如下:

“未捕获的SyntaxError:eval()处输入的意外结束”

c# asp.net-mvc view kendo-grid bootbox
1个回答
0
投票

据我所知,你需要在bootbox弹出窗口中呈现Kendo下拉列表。你可以这样做:

剃刀C#:

@{
    string htmlstring = "";
    htmlstring += "<select id='userRoles'>";
    foreach (Role role in ViewBag.Roles)
    {
        htmlstring += "<option value='" + role.RoleID + "'>" + role.RoleName + "</option>";
    }
    htmlstring += "</select>";
}

脚本:

    <script>
        var renderString = "@Html.Raw(htmlstring)";
        var dialog = bootbox.dialog({
            title: 'A custom dialog with init',
            message: renderString
        });

        var required = $("#userRoles").kendoMultiSelect().data("kendoMultiSelect");

    </script>

显示为:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.