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.



   @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" />


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);




@model string


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?


source to share

2 answers

Make sure you link to MS files

 <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>


Also I think you want to post and not receive.



Double check that jquery.unobtrusive-ajax.js is loaded correctly on the page and validate your product code name in the input tag (must be equal to the action parameter).

Let me know if this solves your problem.



All Articles