【发布时间】:2014-12-08 21:15:42
【问题描述】:
我有一个剑道窗口,我想根据下拉菜单中的选择来填充它。我试过在打开时刷新窗口,但我can't figure out how to make that work。换档,我想知道是否可以改为在窗口声明本身内向控制器发送一个可变参数,然后执行一个简单的 window.refresh (而不是编写刷新以命中特定控制器,这是行不通的)。
我的意思是这样的:
@(Html.Kendo().Window()
.Name("EditWindow")
.Title("Edit Contact")
.LoadContentFrom("_ContactEdit", "Contacts", new { selectedContact = $("#ContactId").data("kendoComboBox").value() })
.Content("Loading...")
.Visible(false)
.Draggable()
.Resizable()
.Width(400)
.Modal(true)
.Actions(actions => actions.Pin().Minimize().Maximize().Close())
)
或者这个:
@(Html.Kendo().Window()
.Name("EditWindow")
.Title("Edit Contact")
.LoadContentFrom("_ContactEdit", "Contacts", new { selectedContact = getContact() })
.Content("Loading...")
.Visible(false)
.Draggable()
.Resizable()
.Width(400)
.Modal(true)
.Actions(actions => actions.Pin().Minimize().Maximize().Close())
)
显然这些都不起作用,但我想知道是否有其他方法可以填写此字段?
谢谢!
edit:从控制器和窗口/局部视图添加相关代码。我的控制器现在被击中,但我的窗口没有提取正确的数据。有什么想法吗?
窗口:
@model [taking out company info].Contact
@using Kendo.Mvc.Extensions
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset id="infoForm">Hello, world.
@Html.HiddenFor(model => model.ContactId, new { id = "EditWindowId" })
<br />
<label id ="ContactNameID" style="width: 130px;">Contact Name</label>
<span>
@Html.TextBoxFor(model => model.FullName, new { type = "text", id = "EditWindowName", @class = "k-textbox form-control", style = "width: 200px; cursor:default" })
</span><br />
</fieldset>
}
控制器:
[HttpGet]
public ActionResult _ContactEdit(int selectedContact)
{
var entities = from r in dbContext.Contacts
where r.ContactId == selectedContact
select r;
if (entities.Any())
{ return PartialView(entities.First()); }
else
{ return HttpNotFound("Contact does not exist."); }
}
【问题讨论】:
标签: asp.net-mvc kendo-ui html-helper kendo-window