Implementing the auto save functionality for my page. so after certain interval calling action Autosave(). But my page having begin form including the Partial view. The code for after interval call is working fine.

<script type="text/javascript">
    window.setInterval(function () {       
        var form = $("#addpost");
        $.ajax({
            url: '@Url.Action("AutoSavePostAction", "MyControllerName")',
            data: form.serialize(),
            type: 'POST',
            success: function (data) {
                $("#Id").val(data);
            }
        });
    }, 30000); 

View is :

@using (Html.BeginForm("SavePostAction", "MyControllerName", FormMethod.Post, new { enctype = "multipart/form-data", id="addpost" }))
{
    .................
    @Html.Partial("_TextPostPartial", Model);
    .................
}

SavePostAction is after calling submit. On this submission, getting the value from Partial view, which is not an issue. But in ajax call somehow partial view does not included in serialization. Here _TextPostPartial having CKEditor which is strongly bind with Model. Like Partial view having :

<textarea id="Description" name="Description">@Html.Raw(Model.Description)</textarea>

Edited:

[HttpPost]
public ActionResult AutoSavePostAction(PostDTO postDTO, FormCollection postFormCollection)
{
}

[HttpPost]
[MemberFunction]
public ActionResult SavePostAction(PostDTO postDTO, FormCollection postFormCollection)
 {
 }

Related posts

Recent Viewed