如何在Asp.Net MVC中使用按钮内部执行操作时保留弹出窗口,以便仅在弹出窗口中显示操作结果? [英] How to retain popup while doing an action with a button inside it in Asp.Net MVC so that the action result will be displayed in the pop up only ?

查看:283
本文介绍了如何在Asp.Net MVC中使用按钮内部执行操作时保留弹出窗口,以便仅在弹出窗口中显示操作结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC 5应用程序。



在我的页面中,我有一个ADD按钮,它会弹出一个窗口(jquery对话框)并在其中呈现ADD视图。如果用户单击添加按钮,它将更新数据库并重定向到网格页面。但是如果存在任何验证错误(包括服务器端验证),我将返回具有错误的模型的相同视图。但它正在关闭弹出窗口并在独立页面中显示。



我的要求是通过保留弹出窗口来显示控件的验证错误。



任何人都可以请帮忙吗?

I have a MVC 5 application.

In my page I have an ADD button which will pop up a window (jquery dialog) and render the ADD view inside that. If the user clicks the Add button it will update the DB and redirect to the grid page. But if there are any validation errors (including the server side validations), I am returning the same view with the model having errors. But it is closing the popup and showing in a standalone page.

My requirement is to show the validation errors against the controls by retaining the popup.

Can anyone please help on this ?

推荐答案

你需要设置标志来确定是提交还是一般渲染视图。如果表单验证失败,则返回错误消息并检查和显示弹出窗口。
you need to set flag to determine from is submit or general render view . if the form validation failed return error message check on the and show popup.


这篇关于如何在Asp.Net MVC中使用按钮内部执行操作时保留弹出窗口,以便仅在弹出窗口中显示操作结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆