MVC3远程验证
我目前正在使用 MVC3 设置远程验证,以便用户在其选择的用户名已存在时收到警报。除了最重要的部分(未显示错误消息)之外,一切都已设置并正常工作。如果我提交表单,则会在刷新页面时显示错误消息,并添加相关的模型状态错误。
是否有办法用 Json 结果刷新模型验证摘要?
I am currently in the proccess of setting up remote validation using MVC3 so that a user is alerted if their chosen username already exists. Everything is set up and working correctly appart from the most important part, the error message not being displayed. If I submit the form the error message is displayed as the the page is refreshed with the relevant model state error added.
Is there anyway to refresh the model validation summary with a Json result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
示例代码:
Web.config 必须包含以下内容:
视图是这样的:
这是传递给视图的模型:
这是在控制器中
这将尝试将数字附加到名称,直到找到可用的用户名并执行类似的操作这无需进行完整的回发:
Sample code:
Web.config must contain this:
The view is like this:
This is the model being passed to the View:
This is in the controller
This will try appending numbers to the name until it finds an available username and will do something like this without doing a full postback: