mvc部分视图表单提交错误?

时间:2017-07-12 05:01:15

标签: .net asp.net-mvc asp.net-mvc-partialview

我有MVC partial view名为BasicUserDetailsDisplay

 public PartialViewResult BasicUserDetailsDisplay(string id)
        {
            var user = userService.GetUserInfo(id);
            return PartialView("_BasicUserDetailsDisplay", user);
        }

BasicUserDetailsDisplay - 局部视图

    @model Udio.Data.ViewModels.UserItemViewModel
    @{
        ViewBag.Title = "Index";
        Layout = "~/Views/Shared/_LayoutMain.cshtml";
    }
            <div class="tab-content">
                    <!--User Reviews Tab-->
                    <div class="tab-pane active" id="reviews" role="tabpanel">
                        @Html.Action("UserReviewsTab", "User", new { id = Model.Id }) 
                    </div>                
                    @*Profile Settings Tab*@
                    <div class="tab-pane" id="profile_settings" role="tabpanel">
                        @Html.Action("UserProfileSettingsTab", "User", new { id = Model.Id })                    
                    </div>
                    <!--Nic/Passport Docs Tab-->
                    <div class="tab-pane" id="nic_docs_tab_id" role="tabpanel">
                        @Html.Action("NicPassportDocumentTab", "User", new { id = Model.Id })
                    </div>
                    @*Driving License Docs Tab*@
                    <div class="tab-pane" id="dlicense_docs_tab_id" role="tabpanel">
                        @Html.Action("DrivingLicenseDocumentTab", "User", new { id = Model.Id })
                    </div>

                    @*>Vehicle Docs Tab*@
                    <div class="tab-pane" id="vehicle_docs_tab_id" role="tabpanel">
                       @Html.Action("VehicleDocumentTab", "User", new { id = Model.Id })
                    </div>

</div>

在里面我有3个标签作为部分视图 那些提交表格。 一个选项卡如下:

public PartialViewResult NicPassportDocumentTab(string id)
{
    var user = userService.GetUserInfo(id);
    return PartialView("_NicPassportDocumentTab", user);
}
/// <summary>
/// To udate  nic/passport and do the verification
/// </summary>
/// <param name="vm"></param>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
public PartialViewResult NicPassportDocumentTab(UserItemViewModel vm)
{

    try
    {
        ModelState.AddModelError("NicPassport", "NicPassport Can not be empty.");
        //if (!string.IsNullOrEmpty(vm.NicPassport))
        //{

            userService.UpdateUserDetails(vm);
            var user = userService.GetUserInfo(vm.Id);
            //return PartialView("UserProfileMain", user);

        //}
        //else
        //{
        //    ModelState.AddModelError("NicPassport", "NicPassport Can not be empty.");
        //}
    }
    catch (Exception ex)
    {
        ModelState.AddModelError("NicPassport", "Submission failed.");
    }
    return PartialView("UserProfileMain", vm);
}

NicPassportDocumentTab部分视图

@model Udio.Data.ViewModels.UserItemViewModel
               @using (Html.BeginForm((string)ViewBag.Action, "User", FormMethod.Post, new { @class = "form p-t-20", enctype = "multipart/form-data" }))
    {
        @Html.AntiForgeryToken()

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="form p-t-20">
            <div class="form-group">
                @Html.LabelFor(model => model.NicPassport)
                <div class="input-group">
                    @Html.TextBoxFor(model => model.NicPassport, new { @class = "form-control  form-control-line" })
                    @Html.ValidationMessageFor(model => model.NicPassport, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="input-group">
                <div class="form-group">
                    <div class="icheck-list">
                        @Html.CheckBoxFor(model => model.IsNicPassPortVerified, new { @class = "check" })
                        @Html.LabelFor(model => model.IsNicPassPortVerified)
                    </div>
                </div>
            </div>

            <div class="text-left">
                <input type="submit" value="Verify" class="btn btn-success" />
            </div>
        </div>
        @Html.HiddenFor(model => model.DateOfBirth)
        @Html.HiddenFor(model => model.Gender)
        @Html.HiddenFor(model => model.FullName)
        @Html.HiddenFor(model => model.NicPassport)
        @Html.HiddenFor(model => model.NicPassportImage1)
        @Html.HiddenFor(model => model.NicPassportImage2)
        @Html.HiddenFor(model => model.PhoneNumber)
        @Html.HiddenFor(model => model.ProfilePictureUrl)
        @Html.HiddenFor(model => model.DrivingLicenseNo)
        @Html.HiddenFor(model => model.DrivingLicenseNoImage1)
        @Html.HiddenFor(model => model.DrivingLicenseNoImage2)
        @Html.HiddenFor(model => model.Email)
        @Html.HiddenFor(model => model.FacebookFriendsCount)
        @Html.HiddenFor(model => model.FacebookProfileUrl)
        @Html.HiddenFor(model => model.IdentificationType)
        @Html.HiddenFor(model => model.IsDriverInfoUpdated)
        @Html.HiddenFor(model => model.IsFacebookVerified)
        @Html.HiddenFor(model => model.IsDrivingLicenseVerified)
    }

以上post方法连续执行并在BasicUserDetailsDisplay partial view

中给出错误
  

System.InsufficientExecutionStackException:&#39;堆栈不足以安全地继续执行程序。这可能是因为调用堆栈上的函数太多或堆栈上的函数占用太多堆栈空间。&#39;

当我提交表单并返回BasicUserDetailsDisplay(主要部分视图)时,我收到上述错误。

这是UserProfileMain视图:

@model Udio.Data.ViewModels.UserItemViewModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}


<div class="row">
    <!-- Column -->
    @*userbasic details display*@
    <div class="col-lg-4 col-xlg-3 col-md-5">
        <div class="card">
            @Html.Action("BasicUserDetailsDisplay", "User", new { id = Model.Id})             
        </div>
    </div>
    @*userbasic details display*@
    <!-- Column -->
    <div class="col-lg-8 col-xlg-9 col-md-7">
        <div class="card">
            <!-- Nav tabs -->
            <ul class="nav nav-tabs profile-tab" role="tablist">
                <li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#reviews" role="tab">Reviews</a> </li>
                <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#profile_settings" role="tab">Profile Settings</a> </li>
                <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#nic_docs_tab_id" role="tab">Nic/Passport Docs</a> </li>
                @if (Model.IsDriverInfoUpdated)
                {
                    <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#dlicense_docs_tab_id" role="tab">Driving License Docs</a> </li>
                    <li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#vehicle_docs_tab_id" role="tab">Vehicle Docs</a> </li>
                }

            </ul>
            <!-- Tab panes -->
            <div class="tab-content">
                <!--User Reviews Tab-->
                <div class="tab-pane active" id="reviews" role="tabpanel">
                    @Html.Action("UserReviewsTab", "User", new { id = Model.Id }) 
                </div>                
                @*Profile Settings Tab*@
                <div class="tab-pane" id="profile_settings" role="tabpanel">
                    @Html.Action("UserProfileSettingsTab", "User", new { id = Model.Id })                    
                </div>
                <!--Nic/Passport Docs Tab-->
                <div class="tab-pane" id="nic_docs_tab_id" role="tabpanel">
                    @Html.Action("NicPassportDocumentTab", "User", new { id = Model.Id })
                </div>
                @*Driving License Docs Tab*@
                <div class="tab-pane" id="dlicense_docs_tab_id" role="tabpanel">
                    @Html.Action("DrivingLicenseDocumentTab", "User", new { id = Model.Id })
                </div>

                @*>Vehicle Docs Tab*@
                <div class="tab-pane" id="vehicle_docs_tab_id" role="tabpanel">
                   @Html.Action("VehicleDocumentTab", "User", new { id = Model.Id })
                </div>

            </div>
        </div>
    </div>
    <!-- Column -->
</div>

@section SectionTitle
{
   Profile
}

0 个答案:

没有答案