当我在 ASP.Net 中使用 CustomValidator 服务器端验证时 Simplemodal 关闭
我正在构建一个 asp.net 应用程序,该应用程序在更新面板内有一个 gridview 。
在此网格中,我添加了一个命令字段,该字段引发服务器事件以填充模式弹出隐藏 div 部分上的字段,为用户显示模式并等待。
用户正在编辑字段并单击“保存”。
链接到这些字段我有几个验证控件。有些是标准的,有些是定制的。
当我的 customValidator 使用客户端脚本时,一切都很顺利;如果一个字段无效,则显示摘要部分,并且模式仍然可见。
但是...(因为没有但是我不必写这个问题)
当我的 CustomValidator 是服务器端验证时,即使它失败,模式表单也会关闭,甚至会引发我的保存按钮。
我使用 CustomValidator 因为该验证需要实时数据库验证。
我的问题是:如果返回 false (e.isvalid = false),如何使服务器端验证保持模式弹出窗口打开?
如果这是不可能的..我尝试调用: ScriptManager.RegisterStartupScript((Control)sender, sender.GetType(), Guid.NewGuid().ToString(), "$('#basic-modal-content-province ').modal({appendTo:'form', persist:true});", true);
但没有成功->它说 $ 未定义
我使用 http://www.ericmmartin.com/projects/simplemodal/< /a>
我对 JQuery 和 AJAX 完全陌生,感谢您的帮助
Steph
I'am building an asp.net application that have a gridview inside an update pannel.
In this grid, I added a command field that raise a server event to fill fields on my modal popup hiden div section, show the modal for the the user and wait.
The user is editing the fields and click save.
Linked to these fields I have several Validation control. some are standard, same are custom.
When my customValidator are using client side script, everything is goiing fine; if one field is invalide, the summary section is displayed and the modal for still visible.
But ... (cause without a but I won't have to writte this question)
When my CustomValidator is a server side validation, even if it fail, the modal form is closed and my save button even is raised.
I use a CustomValidator because that validation need a real time database verification.
my issue is : how may I make this server side validation keeping the modal popup open if it return false (e.isvalid = false) ?
If this is not possible .. i tried to call the : ScriptManager.RegisterStartupScript((Control)sender, sender.GetType(), Guid.NewGuid().ToString(), "$('#basic-modal-content-province').modal({appendTo:'form', persist:true});", true);
but it did not work -> it say that $ is not defined
I use http://www.ericmmartin.com/projects/simplemodal/
I am totally new to JQuery and AJAX, thanks for your help
Steph
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将使用带有 AJAX 模式扩展器的自定义验证器,然后在模式中提交数据后,通过检查页面是否有效来检查是否存在错误,如果无效,则使用其 show() 函数使扩展器显示- 例如使用 c#:
除此之外,我不确定是否还有其他方法可以使用自定义验证器保持模式打开,因为它不会回发。
I would use the custom validator with the AJAX modal extender and then once you submit the data in the modal check to see if there are errors by checking if the page is valid, if not valid then make the extender show using it’s show() function - for example with c#:
Outside of that I'm not sure there's any other way to keep the modal open with the custom validator since it doesn't post back.