Posts

Showing posts with the label Partial Views

Can You Just Update A Partial View Instead Of Full Page Post?

Answer : Not without jQuery. What you would have to do is put your Partial in a div, something like: <div id="partial"> @Html.Partial("YourPartial") </div> Then, to update (for example clicking a button with the id button ), you could do: $("#button").click(function () { $.ajax({ url: "YourController/GetData", type: "get", data: $("form").serialize(), //if you need to post Model data, use this success: function (result) { $("#partial").html(result); } }); }) Then your action would look something like: public ActionResult GetData(YourModel model) //that's if you need the model { //do whatever return View(model); } Actually, if your Partial has a child action method, you can post (or even use an anchor link) directly to the child action and get an Ajax-like affect. We do this in several Views. The syntax is @Html.Action...