无法在模态弹出窗口中呈现PartialView(Kendo窗口)

时间:2015-05-28 13:44:50

标签: asp.net-mvc kendo-ui modal-dialog partial-views popupwindow

在我的MVC应用程序中,我在单击“创建”按钮后打开一个弹出窗口,但我无法在其中渲染我的部分视图渲染。我想要做的只是在弹出对话框中渲染部分视图,然后传递模型和一些参数(即id = 1)。你能告诉我哪里出错了吗?提前谢谢。

注意:使用 bootstrap模式的任何解决方案也会受到赞赏......

查看:

@(Html.Kendo().Window()
    .Name("CreateWindow")
    .Title("Create Employee")
    .Visible(false)
    .Draggable(true)
    .LoadContentFrom("_Create", "Employee")
    .Width(800)
    .Modal(true)
    .Content("Loading Part List Info...")
    .Draggable()
    .Resizable()
)


<script type='text/javascript'>
$(function () {
    // When your button is clicked
    $('#createbtn').click(function () {
        var createWindow = $('#CreateWindow').data('kendoWindow');
        createWindow.center().open();
    });
});
</script>


控制器:

[HttpGet]
public ActionResult _Create()
{
    var model = repository.Employee;
    return PartialView(model);
}


PartialView:

@model Employee

<div>MY PARTIAL VIEW CONTENT GOES HERE ...</div>


1 个答案:

答案 0 :(得分:2)

这是我的工作代码,希望它能为您提供帮助:

查看:

new String("xyz") <--there are two objects 
"abc"   <-- kinda obvious
x + y  <-- String are unmodifiable thus this is a new object

<强> PartialView:

@{ ViewBag.Title = "Test"; }
@Styles.Render("~/Content/kendoui/css")

<input type="button" id="createbtn" value="Test kWindow"/>

@(Html.Kendo().Window()
    .Name("CreateWindow")
    .Title("Create Employee")
    .Visible(false)
    .Draggable(true)
    .LoadContentFrom("_Create", "Employee", new { id = 1 })
    .Width(800)
    .Modal(true)
    .Content("Loading Part List Info...")
    .Draggable()
    .Resizable()
)

@Scripts.Render("~/bundles/kendoui")
<script type='text/javascript'>
$(function () {
    // When your button is clicked
    $('#createbtn').click(function () {
        var createWindow = $('#CreateWindow').data('kendoWindow');
        createWindow.center().open();
    });
});
</script>

<强>控制器:

@model Banov.Controllers.Employee
<div>MY PARTIAL VIEW CONTENT GOES HERE ...</div>
<div>@(Model.Id)</div>
<div>@(Model.FirstName)</div>
<div>@(Model.LastName)</div>