Ajax.beginForm() cannot get post value

125 views Asked by At

Guys. I Cannot get post value from ajax.beginform() when building mvc4 website. help me, thanks.:)

//View

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@using (Ajax.BeginForm("Ajax_Search_post", new AjaxOptions { UpdateTargetId = "ajax1"}))
{
    @Html.TextBox("search1")       
    <input type="submit" value="Ajax_Search" />
}    
    <div id="ajax1"></div>

//controler

[HttpPost]
public ActionResult Ajax_Search_post(string search1)
{  //..but i got search1=null here          
    return Content(search1);          
}

So, how can i get "search1" value? PS: i can get "search1" value from 'get' method, but what about the 'post' way?

1

There are 1 answers

1
Razack On

Please use

<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

Hope it will work.I couldn't see any other things missing in your code.