Submitting partial view data from parent view

后端 未结 4 672
星月不相逢
星月不相逢 2020-12-10 06:13

How to submit partial view data from parent view .

I am newbie to MVC,
I have created a partial view _CurrentData which contains editor control

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 07:16

    Solution 1:

    You can simply wrap inputs in main page inside an Ajax form element and also call the @Html.Partial("_CurrentData", Model.CurrentItemDetails) inside it and everything will work fine.

    Solution 2:

    Without using form tag with some JavaScript code to find target inputs just after clicking on btnSubmit element (define click event) then serialize them to prepare for sending to server's action method.

    Common part of both Solutions is writing an ajax method which responds to update the page without refresh like :

    public JsonResult GetResponse(ItemDetails model) {            
        return Json(/*data*/, /*behavior*/);
    }
    

提交回复
热议问题