确定是否页面是有效的在JavaScript中 - ASP.NET [英] Determine if page is valid in JavaScript - ASP.NET
问题描述
什么是确定一个ASPX页面上的表单中的JavaScript有效的最佳方式?
What is the best way to determine if a form on an ASPX page is valid in JavaScript?
我想确认是使用JavaScript打开了一个用户控件的验证 window.showModalDialog()
和检查服务器上的Page.IsValid属性侧不工作。我使用ASP.NET验证控件的页面验证。
I am trying to check the validation of an user control that was opened using the JavaScript window.showModalDialog()
and checking the 'Page.IsValid' property on the server side does not work. I am using ASP.NET validation controls for page validation.
推荐答案
如果我有一个使用了一堆,我会使用类似code以下,以验证页面ASP.NET验证控件的页面。就输入呼叫提交。希望这code样本将让你开始!
If I have a page that is using a bunch of ASP.NET validation controls I will use code similar to the following to validate the page. Make the call on an input submit. Hopefully this code sample will get you started!
<input type="submit" value="Submit" onclick"ValidatePage();" />
<script type="text/javascript">
function ValidatePage() {
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}
</script>
这篇关于确定是否页面是有效的在JavaScript中 - ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!