我试图使用ajax表单加载特定div的局部视图但是它不能同时工作请点击提交按钮帮助我我需要将我的局部视图加载到div
母版页:
<body>
<form id="form1" runat="server" enctype="multipart/form-data" >
<div>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">PageName</asp:ContentPlaceHolder>
<div id="content">
<div id="sidebar">
<asp:Menu ID="menuBar" StaticEnableDefaultPopOutImage="False" runat="server"
BackColor="Black" DynamicHorizontalOffset="2" Font-Names="Arial" Font-Size="0.8em"
ForeColor="White" StaticSubMenuIndent="10px">
<DynamicHoverStyle BackColor="White" ForeColor="Black" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1px" />
<DynamicMenuItemStyle HorizontalPadding="10px" VerticalPadding="7px" BorderColor="White"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Arial" Font-Size="12px" />
<StaticSelectedStyle BackColor="White" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1px" ForeColor="Black" />
</asp:Menu>
</div>
<div id="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>
</div>
</div>
</form>
查看页面:
<% using (Ajax.BeginForm("GetTruckExpensesChild", new { id="EX1001" }, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "List" }))
{%>
<%: Html.ValidationSummary(true)%>
<div> <input type="submit" name="dina" value="show list" </div>
<div id="List"> </div>
答案 0 :(得分:2)
确保您应该添加以下捆绑包。
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*"));
在HTML中,确保调用两个捆绑包。
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
详细信息请查看此链接 -