在回发

时间:2017-04-20 17:04:29

标签: kendo-ui asp.net-mvc-5 kendo-asp.net-mvc kendo-window

我已经实现了kendo弹出窗口并在其中加载了一个视图。当我尝试进行回发时,视图将作为单独的页面加载而不是在窗口中加载。我该如何解决这个问题。

获取首次在窗口中加载视图的方法

 public ActionResult RequestStatus(int requestId, string projectName, string countryCode)
        {
            RequestStatusUpdateViewModel reqeustStatusUpdateViewModel = new RequestStatusUpdateViewModel();

            reqeustStatusUpdateViewModel.RequestID = requestId;
            reqeustStatusUpdateViewModel.ProjectName = projectName;
            reqeustStatusUpdateViewModel.CountryCode = countryCode;

            if (!ModelState.IsValid)
            {
                // return View("NewRequestView", Mapper.Map<RequestStatusViewModel>(newReqeustViewModel));
                return null;
            }
            return View("EditorTemplates/_RequestStatusView", Mapper.Map<RequestStatusUpdateViewModel>(reqeustStatusUpdateViewModel));

        }

的PostMethod

   [HttpPost]
        public ActionResult RequestStatus_Update(RequestStatusUpdateViewModel requestStatusUpdateViewModel)
        {

            WorkLogViewModel workLogViewModel = new WorkLogViewModel();
            WorkLogRepository workLogRepository = new WorkLogRepository();

            workLogViewModel.WorkLogAppliesToID = 1;
            workLogViewModel.WorkLogTypeCode = "60";
            workLogViewModel.RequestID = requestStatusUpdateViewModel.RequestID;
            workLogViewModel.WorkLogSubject = "Worklog created for Request " + requestStatusUpdateViewModel.RequestID;
            workLogViewModel.WorkLogDetails = requestStatusUpdateViewModel.WorkLogDetails;
            workLogViewModel.IsActive =true;


            if (!ModelState.IsValid)
            {
                return View("_RequestStatusView", Mapper.Map<RequestStatusUpdateViewModel>(requestStatusUpdateViewModel));
            }

            requestRepository.UpdateRequestStatus(Mapper.Map<RequestStatus>(requestStatusUpdateViewModel));
            workLogRepository.CreateWorkLog(Mapper.Map<WorkLog>(workLogViewModel));
            return PartialView("EditorTemplates/_RequestStatusView", Mapper.Map<RequestStatusUpdateViewModel>(requestStatusUpdateViewModel));

        }

查看

@using System.Collections
@model CC.GRP.MCRequest.ViewModels.RequestStatusUpdateViewModel

@{
    Layout = null;
}

<style>

    .statusButtonAlign{

        margin-top:20px;
         margin-right:10px;
         float:right;
    }

     #WorkLogDetails {
        width: 100%;
    }

</style>

@using (Html.BeginForm("RequestStatus_Update", "Request", FormMethod.Post, new { id = "requestStatusform" }))
{

<div class="k-popup-edit-form k-window-content k-content" >
    <div class="k-edit-form-container">
      @Html.HiddenFor(x => x.CountryCode, new { data_bind = "value: CountryCode" })
        <div class="editor-label">
            @Html.LabelFor(model => model.RequestID)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.RequestID, new { htmlAttributes = new { @readonly = "readonly" } })
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.ProjectName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ProjectName, new { htmlAttributes = new { @readonly = "readonly" } })
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.RequestStatus)
            </div>
        <div class="editor-field">
                @(Html.Kendo().ComboBoxFor(model => model.RequestStatusCode)

        .HtmlAttributes(new { style = "width:100%" })
        .DataTextField("Status")
        .Placeholder("Select...")
        .DataValueField("RequestStatusCode")
        .AutoBind(false)
        .Filter("contains")

        .DataSource(dataSource => dataSource

        .Read(read =>
        {
            read.Action("GetRequestStatus", "Request").Data("GetCountryCodeFilter").Type(HttpVerbs.Post);

        }).ServerFiltering(true)


           )
                )
            </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.WorkLogDetails)
        </div>

        <div class="editor-field">
            @Html.TextAreaFor(model => model.WorkLogDetails, new { htmlAttributes = new { cols = "100" } })
        </div>

        <div class="statusButtonAlign">
            <button type="submit" class="k-button k-button-icontext k-primary k-grid-update">Update</button>
            <button type="button" class="k-button k-button-icontext k-grid-cancel">Cancel</button>

        </div>

        </div>

</div>
}
<script>

</script>

1 个答案:

答案 0 :(得分:1)