Reputation: 1007
I m trying to load a partial view in particular div using ajax form begin But it was not working at the sametime please help me while click submit button i need to load my partial view into div
Master Page :
<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>
View Page :
<% 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>
Upvotes: 0
Views: 2174
Reputation: 2365
Make sure you should have the follow bundle addition.
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*"));
And in your HTML, make sure both bundles are called.
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
For detail check this link -
Using AJAX to load a partial view not working
Upvotes: 2