I have read many of similar questions on the web but still can't figure out the problem. My Ajax.BeginForm
returns a message through 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 jquery.unobtrusive-ajax.js
file in _Layout.cshtml
so it seems not be the reason.
Does anyone have idea why the message replace the entire page?