asp.net MVC 4 submit from with ajax call

前端 未结 3 1089
长发绾君心
长发绾君心 2021-01-12 21:57

I have this in the controller:

[HttpPost]
    public ActionResult Create(Student student)
    { //somecode..

and i want to submit this from

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-12 22:37

    Use this, assuming you are using razor views:

    @using (Ajax.BeginForm(new AjaxOptions(){
    HttpMethod = "POST",
        Url = "your controller",
        OnComplete = "some client event"
    })
    {
        
    This is a demo form. @Html.LabelFor(model => model.Name) @Html.TextBoxFor(model => model.Name)
    }

提交回复
热议问题