发生错误或异常时在视图中显示模式弹出窗口 [英] Display modal popup in view when error or exception occurred
本文介绍了发生错误或异常时在视图中显示模式弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在控制器中发生错误时显示一个jQuery模式弹出窗口并显示控制器尝试返回的相同视图。
我们怎么做?
I am trying show a jQuery modal popup when error occurred in controller and display a same view where controller trying return.
How can we do that?
HttpPost
Function Traitement(model As TraitementViewModel) As ActionResult
Dim exception As Exception = Nothing
...
Catch ex As Exception
Exception = ex
End Try
If (exception IsNot Nothing) Then
Return PartialView("Errors", Statics.GetErreursForException(exception))
End If
End Function
我尝试过:
partial查看错误
What I have tried:
partial View "Errors"
<pre>@ModelType IEnumerable(Of String)
<div>
<hr />
<h2>Les erreurs suivantes se sont produites</h2>
<ul>
@code
For Each msg As String In Model
@<li>
@msg
</li>
Next
End Code
</ul>
</div>
推荐答案
jQuery模式是客户端控件。您可能需要使用AJAX来检索服务器错误详细信息,并根据需要将它们显示在模式中。这是一个例子:在MVC控制器弹出的模式中显示错误消息 [ ^ ]
a jQuery modal is a client-side control. You may need to use AJAX to retrieve the server error details and diplay them in the modal as you would want. Here's an example: Show error messages in a modal pop up from an MVC controller[^]
这篇关于发生错误或异常时在视图中显示模式弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文