I want to click the button on the “main view” and populate the partial view in its own . Updated
I have a main view:
@{
using (Ajax.BeginForm("PastClaims", "Claim", FormMethod.Post, new AjaxOptions { UpdateTargetId = "update_panel", InsertionMode = InsertionMode.Replace }, new { @class = "form-horizontal" }))
{
<legend>Submit a Claim</legend>
@Html.EditorForModel()
<div class="controls">
<input id="btnCheckForClaims" type="submit" class="btn btn-primary" value="Submit Claim" />
</div>
}
I need to click the submit button then display this other view:
If I do below then on the page on the initial load it displays the div
<div id="update_panel">@Html.Partial("PastClaims")</div>
If I leave the div blank then I get a new partial view.
<div id="update_panel"></div>
if I leave them null like darrin suggested:
using (Ajax.BeginForm("PastClaims", "Claim", FormMethod.Post, new AjaxOptions { UpdateTargetId = "update_panel", InsertionMode = InsertionMode.Replace }, new { @class = "form-horizontal" }))
I am redirected to the same page (what I want) but the additional partial view is not displayed.
Thanks to Darrin below to get me this far.
You could use an
Ajax.BeginFormin this case:and then the corresponding controller action will return the partial view:
For
Ajax.*helpers to work don’t forget to include thejquery.unobtrusive-ajax.jsscript: