【发布时间】:2012-01-18 12:11:50
【问题描述】:
背景: 我是 MVC asp.net Framework 4 的新手。在我的应用程序中,我希望在用户单击事件时更新部分视图(使用 ActionResult)。在 index.aspx 中,我使用标准的 Ajax.BeginForm 包含一个 div,我在其中呈现部分视图(调用 ActionResult):
*<%using (Ajax.BeginForm("Search", "Home", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "divToUpdate" }))
{ %>
Name
<input id="txtName1" name="RoleName" type="text" value="" />
<br />
<br />
<div id="divToUpdate">
<%--render what you want to update here.. --%>
<%Html.RenderPartial("~/Views/Shared/SecurityMainPartialView.ascx", Model); %>
</div>
<br />
<input type="submit" id="btnSubmit" value="Search" />
<% }%>*
局部视图的更新有效。然而:
问题:
在 Site.Master 中,我有表单标签,我必须删除它,因为部分视图会将操作链接重定向到索引而不是搜索。在删除这个我不能再使用使用 asp.tab 等所需的 asp:scriptmanager 标记...
我收到以下错误:“ScriptManager”类型的 *Control 'ctl00_MainContent_ScriptManager1' 必须放在带有 runat=server.* 的表单标记内,即使在站点主控中的 ActionLinks 上也是如此。
网站主代码:
*<body>
<%-- <form id="form1" runat="server">
--%> <div id="container">
<div id="header">
<h1 style="width: 1207px; margin-left: 0px">PROM (Promise Remote Order Management)</h1>
<div id="menubar">
**<li><%= Html.ActionLink("Home", "Index", "Home")%></li>
<li><%= Html.ActionLink("Security", "SecurityMain", "Security")%></li>
<li style="width: 1208px; height: 0px"><%= Html.ActionLink("About", "About", "Home")%></li>**
</div>
</div>
<div id="content" style="height: 100%; width: 100%;">
<asp:ContentPlaceHolder ID="MainContent" runat="server" >
<p style="height: 132px; margin-top: 0px">
</p>
</asp:ContentPlaceHolder>
</div>
<div id="footer">
<p>© footer stuff goes here!</p>
</div>
</div>
<%-- </form>--%>
</body>
</html>*
问题:
如何在我的 Asp.net MVC 4 应用程序中使用脚本 (ScriptManager)?我使用 MVC ScriptManager 还是其他什么?我知道我们不应该在 MVC 中使用脚本管理器,因为它违反了规则……我的选择是什么。
感谢您的任何帮助。
【问题讨论】: