在我的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>
答案 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>