Ajax.BeginForm replace whole page
I have read many similar questions on the internet, but still cannot figure out the problem. Mine Ajax.BeginForm
returns a message across PartialView
in Controller
, but the string replaces the entire page.
View
:
@using (Ajax.BeginForm("NoMoreItem", "ProductListing",
new AjaxOptions
{
HttpMethod = "get",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = string.Concat("NoMoreItemSection1-", counter)
}, new { @id = string.Concat("NoMoreItemForm1-", counter) }))
{
<input type="hidden" value="@Model.Email" name="email" />
<input type="hidden" value="@i.code" name="code" />
<input type="submit" value="notify me" />
}
</div>
My controller:
public ActionResult NoMoreItem(string email, string productCode)
{
string message;
_waitinglist.Save(email, productCode);
message = "Item added to Waiting List";
return PartialView("ItemAdded", message);
}
ItemAdded
View:
@model string <div> @Model </div>
I referenced the jquery.unobtrusive-ajax.js
file in _Layout.cshtml
, so it doesn't seem to be the reason.
Does anyone have an idea why the post is replacing the entire page?
+3
source to share