Asp.net mvc MVC:当控制器中的ModelState有效时,显示弹出窗口

Asp.net mvc MVC:当控制器中的ModelState有效时,显示弹出窗口,asp.net-mvc,popup,Asp.net Mvc,Popup,在ASP.NET MVC项目中,如果控制器中的ModelState.IsValid为true,我想通知用户他们的项目编号,如果用户单击“确定”或关闭弹出窗口,则返回到另一个页面。我尝试使用System.Windows.Forms.MessageBox来执行此操作,但当应用程序位于服务器中时,弹出窗口将不会显示 这是我在控制器中的部分代码 // POST: CylinderReport/Create [HttpPost] [ValidateAntiForgeryToken] public Acti

在ASP.NET MVC项目中,如果控制器中的ModelState.IsValid为true,我想通知用户他们的项目编号,如果用户单击“确定”或关闭弹出窗口,则返回到另一个页面。我尝试使用System.Windows.Forms.MessageBox来执行此操作,但当应用程序位于服务器中时,弹出窗口将不会显示

这是我在控制器中的部分代码

// POST: CylinderReport/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(ProjectCylinderReport pctForm, string yearList, string searchRptNoString, string searchPCNString, string distList)
{
        if (ModelState.IsValid)
        {
            // report number auto-increment
            int maxReportNum = CylinderReportControllerHelper.GetMaxRptNo(db, ldapUtility);
            int newReportNum = 1;
            if (maxReportNum > 1)
            {
                newReportNum = maxReportNum + 1;
            };

            //var confirm = System.Windows.Forms.MessageBox.Show(("Your Report Number is " + newReportNum), "Confirm", System.Windows.Forms.MessageBoxButtons.OK);
            //if (confirm == System.Windows.Forms.DialogResult.OK)

            return RedirectToAction("Index", new { yearList, searchRptNoString, searchPCNString, distList });
        }
    ....
}
控制

 //var confirm = System.Windows.Forms.MessageBox.Show(("Your Report Number is " + 
     newReportNum), "Confirm", System.Windows.Forms.MessageBoxButtons.OK);
        //if (confirm == System.Windows.Forms.DialogResult.OK)

      // Add TempData
       TempData["MsgAlert"] = "Your Report Number is " + newReportNum"";


        return RedirectToAction("Index", new { yearList, searchRptNoString, 
    searchPCNString, distList });
查看Html添加模式

<div class="modal fade text-left" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel110" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
        <div class="modal-content">
            <div class="modal-header bg-success white">
                <img src="~/Content/WebSiteIMG/bell.gif" style="width:30px" />
                <h5 class="modal-title" id="myModalLabel110">&nbsp;&nbsp; Message &nbsp;&nbsp;</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body text-center">
                <br />
                <h5> @TempData["MsgAlert"]</h5>
                <br />
            </div>
        </div>
    </div>
</div>

消息
&时代;

@TempData[“MsgAlert”]
爪哇

@if(TempData[“MsgAlert”!=null)
{
$('myModal1').modal('show');
$('#myModal1').on('show.bs.modal',function(){
var$me=$(这个);
$me.delay(3000).hide(0,函数(){
$me.modal('hide');
});
});
}
控件

 //var confirm = System.Windows.Forms.MessageBox.Show(("Your Report Number is " + 
     newReportNum), "Confirm", System.Windows.Forms.MessageBoxButtons.OK);
        //if (confirm == System.Windows.Forms.DialogResult.OK)

      // Add TempData
       TempData["MsgAlert"] = "Your Report Number is " + newReportNum"";


        return RedirectToAction("Index", new { yearList, searchRptNoString, 
    searchPCNString, distList });
查看Html添加模式

<div class="modal fade text-left" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel110" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
        <div class="modal-content">
            <div class="modal-header bg-success white">
                <img src="~/Content/WebSiteIMG/bell.gif" style="width:30px" />
                <h5 class="modal-title" id="myModalLabel110">&nbsp;&nbsp; Message &nbsp;&nbsp;</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body text-center">
                <br />
                <h5> @TempData["MsgAlert"]</h5>
                <br />
            </div>
        </div>
    </div>
</div>

消息
&时代;

@TempData[“MsgAlert”]
爪哇

@if(TempData[“MsgAlert”!=null)
{
$('myModal1').modal('show');
$('#myModal1').on('show.bs.modal',function(){
var$me=$(这个);
$me.delay(3000).hide(0,函数(){
$me.modal('hide');
});
});
}