customValidator不起作用 [英] customValidator doesn't work
问题描述
你好,
我有一些代码如下。
似乎customValidator不起作用 - 因为我没有得到任何
留言。
身体:
< asp:table>
< asp:TableRow>
< asp:TableCell>
< asp:RequiredFieldValidator
ControlToValidate =" a_email"
Text =" *"
runat =" server" />
< / asp:TableCell>
< asp:TableCell>电子邮件:< / asp:TableCell>
< ; asp:TableCell>< asp:TextBox id =" a_email" runat =" server"
/>< / asp:TableCell>
< / asp:TableRow>
< asp:TableRow>
< asp:TableCell>
< asp:CustomValidator
ControlToValidate =" a_email"
OnServerValidate =" checkEmail"
Text =" Illegal"
ErrorMessage =" Illegal"
runat = "服务器" />
< / asp:TableCell>
< / asp:TableRow>
< / asp:表>
....
在脚本中:
< script runat =" server" ;>
Sub checkEmail(source as object,args As ServerValidateEventArgs)
args.IsValid = false''只是测试 - 总是假的,但即使这样也不行
工作。
结束子
< / script>
....
我的代码出了什么问题?
谢谢:)
Hello,
I have some code as follows.
It seems that customValidator doesn''t work - because i don''t get any
message.
In the body :
<asp:table>
<asp:TableRow>
<asp:TableCell>
<asp:RequiredFieldValidator
ControlToValidate="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell>email:</asp:TableCell>
<asp:TableCell><asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:CustomValidator
ControlToValidate="a_email"
OnServerValidate="checkEmail"
Text="Illegal"
ErrorMessage="Illegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
....
In the script :
<script runat = "server">
Sub checkEmail(source As object,args As ServerValidateEventArgs)
args.IsValid=false ''just testing - always false, but even this doesn''t
work.
End sub
</script>
....
What is wrong in my code ?
Thanks :)
推荐答案
可能你正在使用< asp:Table>,这是服务器端,而不是客户端。
将其更改为标准HTML< table>验证者应该工作。
先生。 X" < a@b.com>在消息中写道
news:e2 ************** @ TK2MSFTNGP10.phx.gbl ...
Could be you''re using <asp:Table>, which is server side, not client side.
Change it to a standard HTML <table> and the validator should work.
"Mr. x" <a@b.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
你好,>
我有一些代码如下。
似乎customValidator不起作用 - 因为我没有得到任何
消息。
body:
< asp:table>
< asp:TableRow>
< asp:TableCell>
< asp:RequiredFieldValidator
ControlToValidate =" a_email"
Text =" *"
runat =" server" />
< / asp:TableCell>
< asp:TableCell>电子邮件:< / asp:TableCell>
< asp:TableCell>< asp:TextBox id = " a_email" runat =" server"
/>< / asp:TableCell>
< / asp:TableRow>
< asp:TableRow>
< ; asp:TableCell>
< asp:CustomValidator
ControlToValidate =" a_email"
OnServerValidate =" checkEmail"
Text =" Illegal"
ErrorMessage = 非法的
runat =" server" />
< / asp:TableCell>
< / asp:TableRow>
< / asp:表>
...
在脚本中:
< script runat =" server">
Sub checkEmail(source as object,args As ServerValidateEventArgs)
args.IsValid = false''只是测试 - 总是假的,但即使这样也不会起作用。
结束子
< / script>
......
<我的代码有什么问题?
谢谢:)
Hello,
I have some code as follows.
It seems that customValidator doesn''t work - because i don''t get any
message.
In the body :
<asp:table>
<asp:TableRow>
<asp:TableCell>
<asp:RequiredFieldValidator
ControlToValidate="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell>email:</asp:TableCell>
<asp:TableCell><asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:CustomValidator
ControlToValidate="a_email"
OnServerValidate="checkEmail"
Text="Illegal"
ErrorMessage="Illegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
...
In the script :
<script runat = "server">
Sub checkEmail(source As object,args As ServerValidateEventArgs)
args.IsValid=false ''just testing - always false, but even this doesn''t
work.
End sub
</script>
...
What is wrong in my code ?
Thanks :)
你的代码显示你是使用RequiredFieldValidator而不是
CustomValidator,因为这篇文章的主题暗示。这是什么?
" Mr。 X" < a@b.com>在消息中写道
news:e2 ************** @ TK2MSFTNGP10.phx.gbl ...
Your codes shows that you are using a RequiredFieldValidator not a
CustomValidator as this post''s subject implies. Which is it?
"Mr. x" <a@b.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
你好,>
我有一些代码如下。
似乎customValidator不起作用 - 因为我没有得到任何
消息。
body:
< asp:table>
< asp:TableRow>
< asp:TableCell>
< asp:RequiredFieldValidator
ControlToValidate =" a_email"
Text =" *"
runat =" server" />
< / asp:TableCell>
< asp:TableCell>电子邮件:< / asp:TableCell>
< asp:TableCell>< asp:TextBox id = " a_email" runat =" server"
/>< / asp:TableCell>
< / asp:TableRow>
< asp:TableRow>
< ; asp:TableCell>
< asp:CustomValidator
ControlToValidate =" a_email"
OnServerValidate =" checkEmail"
Text =" Illegal"
ErrorMessage = 非法的
runat =" server" />
< / asp:TableCell>
< / asp:TableRow>
< / asp:表>
...
在脚本中:
< script runat =" server">
Sub checkEmail(source as object,args As ServerValidateEventArgs)
args.IsValid = false''只是测试 - 总是假的,但即使这样也不会起作用。
结束子
< / script>
......
<我的代码出了什么问题?
谢谢:)
Hello,
I have some code as follows.
It seems that customValidator doesn''t work - because i don''t get any
message.
In the body :
<asp:table>
<asp:TableRow>
<asp:TableCell>
<asp:RequiredFieldValidator
ControlToValidate="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell>email:</asp:TableCell>
<asp:TableCell><asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:CustomValidator
ControlToValidate="a_email"
OnServerValidate="checkEmail"
Text="Illegal"
ErrorMessage="Illegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
...
In the script :
<script runat = "server">
Sub checkEmail(source As object,args As ServerValidateEventArgs)
args.IsValid=false ''just testing - always false, but even this doesn''t
work.
End sub
</script>
...
What is wrong in my code ?
Thanks :)
每个都有一个。他必须已经弄清楚了,因为他没有回复
邮寄。
Scott M. < S - *** @ BADSPAMsnet.net>在消息中写道
news:%2 ****************** @ TK2MSFTNGP12.phx.gbl ...
There is one of each... He must''ve figured it out as he hasn''t replied to
either post.
"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
您的代码显示您正在使用RequiredFieldValidator而不是
CustomValidator,因为此帖子的主题暗示。这是什么?
" Mr。 X" < a@b.com>在消息中写道
新闻:e2 ************** @ TK2MSFTNGP10.phx.gbl ...
Your codes shows that you are using a RequiredFieldValidator not a
CustomValidator as this post''s subject implies. Which is it?
"Mr. x" <a@b.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
你好,
>我有一些代码如下。
似乎customValidator不起作用 - 因为我没有得到任何
消息。
在体内:
< asp:table>
< asp:TableRow>
< asp:TableCell>
< asp:RequiredFieldValidator
ControlToValidate =" a_email" ;
Text =" *"
runat =" server" />
< / asp:TableCell>
< asp:TableCell>电子邮件:< / asp:TableCell>
< asp:TableCell>< asp:TextBox id = " a_email" runat =" server"
/>< / asp:TableCell>
< / asp:TableRow>
< asp:TableRow>
< ; asp:TableCell>
< asp:CustomValidator
ControlToValidate =" a_email"
OnServerValidate =" checkEmail"
Text =" Illegal"
ErrorMessage = 非法的
runat =" server" />
< / asp:TableCell>
< / asp:TableRow>
< / asp:表>
...
在脚本中:
< script runat =" server">
Sub checkEmail(source as object,args As ServerValidateEventArgs)
args.IsValid = false''只是测试 - 总是假的,但即使这样也不会起作用。
结束子
< / script>
......
<我的代码出了什么问题?
谢谢:)
Hello,
I have some code as follows.
It seems that customValidator doesn''t work - because i don''t get any
message.
In the body :
<asp:table>
<asp:TableRow>
<asp:TableCell>
<asp:RequiredFieldValidator
ControlToValidate="a_email"
Text="*"
runat="server" />
</asp:TableCell>
<asp:TableCell>email:</asp:TableCell>
<asp:TableCell><asp:TextBox id="a_email" runat="server"
/></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:CustomValidator
ControlToValidate="a_email"
OnServerValidate="checkEmail"
Text="Illegal"
ErrorMessage="Illegal"
runat="server" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
...
In the script :
<script runat = "server">
Sub checkEmail(source As object,args As ServerValidateEventArgs)
args.IsValid=false ''just testing - always false, but even this doesn''t
work.
End sub
</script>
...
What is wrong in my code ?
Thanks :)
这篇关于customValidator不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!