ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Update (Refresh) DIV content using Ajax.BeginForm on Button Click in ASP.Net MVC<p>Hi&nbsp;nedash,</p> <p>I have created an example. Refer below sample code.</p> <p><strong>Step 1:</strong> Verify you have Microsoft jQuery Unobtrusive Ajax in your script folder.</p> <p>If not then install package using the following command in Nuget:&nbsp;Install-Package Microsoft.jQuery.Unobtrusive.Ajax -Version 3.2.3</p> <p><strong>Step 2:</strong> Create Controller, Model and View in your MVC application.</p> <p><strong>Step 3:</strong> Include the script file in your project (used in code).</p> <p><strong>Step 4:</strong> Create Partial view&nbsp;that you want to update in the Ajax.BeginForm submit.</p> <p><strong>Step 5:</strong> Add Ajax.BeginForm and pass&nbsp;Action Name, Controller Name, AjaxOption.</p> <p><span style="text-decoration: underline;"><strong>Database</strong></span></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-Microsoft-Northwind-and-Pubs-Sample-databases-in-SQL-Server-Management-Studio.aspx" target="_blank">Download Northwind Database</a></p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { NorthwindEntities entities = new NorthwindEntities(); // GET: Home public ActionResult Index() { var Model = entities.Customers.Take(10).ToList(); return View(Model); } public ActionResult SearchInfo(string txtname) { IEnumerable&lt;Customer&gt; Model = entities.Customers.Where(p =&gt; p.ContactName.Contains(txtname)).Take(10).ToList(); return PartialView(&#34;_PartialView&#34;, Model); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">@model IEnumerable&lt;_Ajax_BeginForm.Customer&gt; @{ Layout = null; } &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name=&#34;viewport&#34; content=&#34;width=device-width&#34; /&gt; &lt;title&gt;Index&lt;/title&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;@Url.Content(&#34;~/Scripts/jquery-1.10.2.js&#34;)&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;@Url.Content(&#34;~/Scripts/jquery.unobtrusive-ajax.min.js&#34;)&#34;&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; @using (Ajax.BeginForm(&#34;SearchInfo&#34;, &#34;Home&#34;, new AjaxOptions { UpdateTargetId = &#34;divajax&#34;, HttpMethod = &#34;Post&#34;, InsertionMode = InsertionMode.Replace })) { @Html.TextBox(&#34;txtname&#34;); &lt;input type=&#34;submit&#34; name=&#34;btnsearch&#34; value=&#34;Search&#34; /&gt; } &lt;div id=&#34;divajax&#34;&gt; @{Html.RenderPartial(&#34;_PartialView&#34;, Model);} &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p><strong><span style="text-decoration: underline;">_PartialView</span></strong></p> <pre class="brush: html">@model IEnumerable&lt;_Ajax_BeginForm.Customer&gt; &lt;table class=&#34;table&#34;&gt; &lt;tr&gt; &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.ContactName)&lt;/th&gt; &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Address)&lt;/th&gt; &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.City)&lt;/th&gt; &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.Country)&lt;/th&gt; &lt;/tr&gt; @foreach (var item in Model) { &lt;tr&gt; &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.ContactName)&lt;/td&gt; &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.Address)&lt;/td&gt; &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.City)&lt;/td&gt; &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.Country)&lt;/td&gt; &lt;/tr&gt; } &lt;/table&gt; </pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/Hd0z3Ic.gif" alt="" width="471" height="388" /></span></strong></p>https://www.aspforums.net:443/Threads/580978/Update-Refresh-DIV-content-using-AjaxBeginForm-on-Button-Click-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/580978/Update-Refresh-DIV-content-using-AjaxBeginForm-on-Button-Click-in-ASPNet-MVC/Mon, 18 Mar 2019 12:09:45 GMT