ASP.NET 2.0 clientvalidation函数何时不应该触发 [英] ASP.NET 2.0 clientvalidationfunction Firing When it Shouldn't

查看:75
本文介绍了ASP.NET 2.0 clientvalidation函数何时不应该触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有文本框和customvalidator的ASP.NET表单。

表格继承自基本向导类,带有后退,下一步和取消

按钮。 Cancel按钮的CausesValidation属性被设置为

为false,但当敲击取消按钮时,javascript clientvalidation函数正在触发。通过调试器,

派生表单的Page_Load上的

CausesValidation属性设置为false。为什么即使

causevalidation为false,客户端javascript也会被解雇?我怎么阻止这个?

I''ve got an ASP.NET form with a textbox and a customvalidator. The
form inherits from a base wizard class with back, next and cancel
buttons. The CausesValidation property of the Cancel button gets set
to false, yet the javascript clientvalidationfunction is firing when
the cancel button is hit. Running through the debugger, the
CausesValidation property is set to false on the Page_Load of the
derived form. Why is the clientside javascript firing even though
causesvalidation is false? How do I stop this?

推荐答案

你好,


请查看源码并粘贴那些按钮点击这里代码,所以我们

可以确保它做客户端验证。如果是onclick,你会在onclick上看到一个

Page_ClientValidate()调用。还要超载

OnPreRender()并确保不更改CausesValidation。如果你想发布它,我想要看看上面提到的那个HTML。


-sam

Hello,

Please do a view source and paste that buttons onclick code here so we
can be sure its doing client side validation. You will see a
Page_ClientValidate() call on the onclick if it is. Also overload
OnPreRender() and make sure CausesValidation is not changed. I''d like
to see that html mentioned above if you care to post it.

-sam


以下是''查看源''的相关代码:

< script language =" javascript">

<! -

函数OnPasswordValidate(来源,参数){

arguments.IsValid = pwd1.value == pwd2.value;

}

// - >


< td colspan =" 2">< input name =" _ctl_AuthPage:_ctl22:tbxPassword" ;

type =" password" ID = QUOT; _ctl_AuthPage__ctl22_tbxPassword" tabindex =" 5"

class =" TextBox"风格= QUOT;宽度:350像素;" />< / td>

< td align =" right">< span id =" _ctl_AuthPage__ctl22_pwdCustomValidator"

title ="密码必须包含至少6个字符

evaluationfunction =" CustomValidatorEvaluateIsValid"

clientvalidationfunction =" OnPasswordValidate"

style =" color:Red ; visibility:hidden;">< img align =''absmiddle''

src =''/ proCube / images / err.gif''/>< / span>< ; / td>


< a id =" _ctl_AuthPage__ctl22__btnCancel" style =" MARGIN-LEFT:10px"

class =" Button"的tabindex = QUOT; 204" direct =" true"

href =" javascript :__ doPostBack(''_ ctl_AuthPage
Here is the relevant code form the ''view source'':
<script language="javascript">
<!--
function OnPasswordValidate(source, arguments) {
arguments.IsValid = pwd1.value == pwd2.value;
}
// -->

<td colspan="2"><input name="_ctl_AuthPage:_ctl22:tbxPassword"
type="password" id="_ctl_AuthPage__ctl22_tbxPassword" tabindex="5"
class="TextBox" style="width:350px;" /></td>
<td align="right"><span id="_ctl_AuthPage__ctl22_pwdCustomValidator"
title="Password must contain at least 6 characters"
evaluationfunction="CustomValidatorEvaluateIsValid "
clientvalidationfunction="OnPasswordValidate"
style="color:Red;visibility:hidden;"><img align=''absmiddle''
src=''/proCube/images/err.gif''/></span></td>

<a id="_ctl_AuthPage__ctl22__btnCancel" style="MARGIN-LEFT: 10px"
class="Button" tabindex="204" direct="true"
href="javascript:__doPostBack(''_ctl_AuthPage


_ctl2 2


这篇关于ASP.NET 2.0 clientvalidation函数何时不应该触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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