ASP.NET:自定义验证器不起作用! [英] ASP.NET: Custom Validator not working!

查看:122
本文介绍了ASP.NET:自定义验证器不起作用!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我似乎遇到了一个非常普遍的问题,关于这个问题,我已经在Google上搜索了多个小时,但是找不到解决方案...

我在ASP.NET中的Custom-Validator无法正常工作!

Hello everybody!

I seem to have a very common problem, about which I have Googled for many hours now, but could not find a solution...

My Custom-Validator in ASP.NET just won''t work!

<asp:CustomValidator
    id="cusvalISBN"
    runat="server"
    ControlToValidate="txtISBN"
    Display="Dynamic"
    ErrorMessage="This ISBN already exists"
    OnServerValidate="isbnDuplication"
    ValidateEmptyText="True">
</asp:CustomValidator>



我的C#代码中的函数从未被触发过.我已经尝试调试,并且所有内容,即使"cusvalISBN.Validate()"也不会调用该函数...

我已经将此验证器与Requiredfieldvalidator结合使用.因此,空文本是不可能的!奇怪的是:几天前我在另一个页面上已经遇到了相同的问题……几个小时后,它突然起作用了.我可以重现为使其起作用而进行的更改.新代码仅被复制和粘贴,但无法正常工作:-(

有什么想法吗?



The function in my C# code is just NEVER being fired. I have tried debugging and everything, even "cusvalISBN.Validate()" does NOT call the function...

I am already using this validator in combination with a Requiredfieldvalidator. So empty text is not possible! The weird thing is: I already had the same problem a few days ago on another page... after some hours, it suddenly worked. I could reproduce the change I had done to make it working. The new code is just copied and pasted and yet, it isn''t working :-(

Any ideas??

推荐答案

嗨nishantsagar83!
非常感谢您的回答!
由于我通常只使用源代码"选项卡,因此我真的希望这样做可以...但是它并没有:(
我的意思是,即使我在设计视图中单击错误文本,我的光标也会跳到自定义验证器"的函数,但它仍然不被称为:-(
那是个错误吗?
Hi nishantsagar83!
Thank you very much for your answer!
Since I usually only use the sourcecode tab, i was really hoping this would do it... but it didn''t:(
I mean, even when i click on the error text in design view, then my cursor jumps to the function for the Custom Validator, but it still is not called :-(
Is that a bug??




尝试切换到设计视图,然后再返回到html视图和代码视图...

听起来很愚蠢..但是它有时还是可以工作的...有时候,方法没有正确绑定,并且在模式之间进行切换使Studio再次将它们正确绑定....

如果您找到合适的解决方案,请告诉我..

thnks ..


try switching to design view and then back to html view and code view...

sounds stupid.. but it does work sometime... thing''s that sometimes the methods are not bound properly and switching between modes makes studio bind them again properly...

do let me know if u find some proper solution..

thnks..


这篇关于ASP.NET:自定义验证器不起作用!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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