MVC显示部分视图以启动模态

时间:2018-08-15 02:28:59

标签: asp.net-mvc bootstrap-modal

美好的一天!如何放置局部视图以引导模态?

我搜索了很多论坛,但没有找到与我的问题相符的内容。我有一个表格,左侧有一个 VIEW 按钮。当用户单击它时,这将触发一个带有内部 Partial View Modal 。父页面将为部分视图控制器提供 四个值

“部分视图”将用作“编辑页面表单”,如果数据库提供的值不正确,则用户可以从模式中对其进行编辑并将其保存到数据库。

是否可以不执行任何脚本就完成?如果没有,那么脚本就可以。

父表

<table id="tablee" class="table table-bordered table-hover table-striped table-responsive">
<thead>
        <tr>
            <th>
                @Html.DisplayName("Action")
            </th>
            <th>
                @Html.DisplayName("Serial Number")
            </th>
            <th>
                @Html.DisplayName("Payer Name")
            </th>
            <th>
                @Html.DisplayName("Payer Address")
            </th>
            <th>
                @Html.DisplayName("Motor No")
            </th>
        </tr>
</thead>
<tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    <a href="@Url.Action("Popup", "Application", new { MotorId= item.motor_id, Serialno = item.serialno, AppNo = item.application_no })" class="btn btn-warning">
                      View
                     <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
                    </a>
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.serialno)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.payername)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.payeraddress)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.motor_no)
                </td>
            </tr>
        }
    </tbody>
</table>

MODAL

<div class="modal fade" id="myModal3" role="dialog">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <center> <h3 class="modal-title"><b>Franchise Details</b></h3></center>
        </div>
        <div class="modal-body">
           @*Partial View*@
        </div>
        <div class="modal-footer">
          <button class="btn" type="button" data-dismiss="modal">Close</button>
        </div>
    </div>
</div>

部分视图控制器

public ActionResult Popup(string Serialno,  string AppNo, string MotorId, string Remarks)
{
var list = (from R in db.vwEtracs_Receipt
           join M in db.vwQVFS_Motor on R.remarks.Substring(5) equals M.motor_no
           join COR in db.vwQVFS_COR on M.motor_id equals COR.motor_id
           join FRAN in db.tbl_FranchiseNo on R.remarks.Substring(5) equals FRAN.franchise_no
           join APP in db.tbl_Application
           on new { R.txndate.Value.Year, M.motor_no }
           equals new { APP.date_created.Value.Year, APP.motor_no }
           where APP.application_no == AppNo && FRAN.franchise_no == Remarks.Substring(5) &&
           M.motor_id == MotorId && R.serialno == Serialno
           select new FranchiseViewModel
           {
           application_no = APP.application_no,
           franchise_no = R.remarks.Substring(0, 4),
           SelectStatus = APP.statusofapplication,
           statusofapplication = db.tbl_StatusofApplication.Select(x => new SelectListItem
           {
           Value = x.id.ToString(),
           Text = x.StatusofApplication
           }),
           frist_name = APP.frist_name,
           middle_name = APP.middle_name,
           surname = APP.surname,
           full_address = APP.full_address,
           motor_id = M.motor_id,
           motor_no = M.motor_no,
           plate_no = M.plate_no,
           year_model = M.year_model,
           cr_no = COR.cr_no
           }).ToList();
return PartialView("Popup",list);
}

PARTIAL VIEW

@model iVehicle.ViewModel.FranchiseViewModel

@Html.EditorFor(x => Model.application_no)
@Html.EditorFor(x => Model.franchise_no)
@Html.DropDownListFor(x => Model.SelectStatus, Model.statusofapplication, "Select Status of Application")
@Html.EditorFor(x => Model.frist_name)
@Html.EditorFor(x => Model.middle_name)
@Html.EditorFor(x => Model.surname)
@Html.EditorFor(x => Model.full_address)
@Html.EditorFor(x => Model.body_color)
@Html.EditorFor(x => Model.chassis_no)
@Html.EditorFor(x => Model.motor_no)
@Html.EditorFor(x => Model.plate_no)
@Html.EditorFor(x => Model.year_model)

谢谢。

0 个答案:

没有答案