如何在弹出窗口中显示模型状态错误 [英] How to show Model state Errors in Pop up

查看:80
本文介绍了如何在弹出窗口中显示模型状态错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我已经实现了验证用户输入信息的代码。



如果用户输入了错误的信息,那么我的模型状态显示文本框旁边的错误。我想在弹出窗口中显示它们。



如何在弹出窗口中显示它们。



请帮助我,





谢谢

解决方案

1-First创建一个html帮助器,用于为弹出窗口生成html标记,并且传递给辅助方法的参数是模型状态错误。下面是获取模型状态中所有错误的代码。

  foreach (ModelState modelState  in  ViewData .ModelState.Values){
foreach (ModelError错误 in modelState.Errors){
DoSomethingWith(错误);
}
}





2 - 将此辅助方法放在母版页中。

3.使用jquery对话框在document.ready中编写代码以便弹出。



http://develoq.net/2011/how-to-create-custom-html-helpers -for-asp-net-mvc-3-and-razor-view-engine / [ ^ ]

希望这会有所帮助。


Hi Friends,

I have implementeed the code that is validating the information which user is entering.

If the user enter the wrong informatoin then my model state showing the error beside the text box.I want to show them in the pop up.

How to show them in the pop up.

Please help me,


Thanks

解决方案

1-First Create an html helper for the generating the html mark up for the pop up and arguments passed to the helper method are the model state errors.below are the code for get all the errors in model state.

foreach (ModelState modelState in ViewData.ModelState.Values) {
    foreach (ModelError error in modelState.Errors) {
        DoSomethingWith(error);
    }
}



2-Put this helper method in master page.
3.Using jquery dialog write code in document.ready for pop up.

http://develoq.net/2011/how-to-create-custom-html-helpers-for-asp-net-mvc-3-and-razor-view-engine/[^]
Hope this helps..


这篇关于如何在弹出窗口中显示模型状态错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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