ASP.NET CustomValidator 尝试匹配 System.EventHandler?
我有标记这样:
<asp:TextBox runat="server" ID="Accountname" />
<asp:CustomValidator runat="server" ControlToValidate="Accountname" OnServerValidate="Accountname_CheckUnique" meta:resourcekey="ACCOUNTNAME_UNAVAILABLE" />
代码隐藏这样:
protected void Accountname_CheckUnique(object source, ServerValidateEventArgs arguments)
{
arguments.IsValid = Foo();
}
哪个工作很好,然后无需更改页面上的任何内容 ASP 现在坚持:
无过载 “Accountname_CheckUnique”匹配 委托“System.EventHandler”
嗯,不,也不应该根据 MSDN。已经很晚了,我很累,有人知道如何解决这个问题或指出我理解中的明显缺陷吗?
编辑:
我还尝试过 += 绑定作为代码隐藏中的事件处理程序,但它仍然需要 EventArgs 签名。使。不,理智。
编辑2:
完全删除并重新创建页面(复制粘贴),问题就消失了。假设某个利基事物造成了一个非常局部的问题。
@MODS:请关闭。
I have markup so:
<asp:TextBox runat="server" ID="Accountname" />
<asp:CustomValidator runat="server" ControlToValidate="Accountname" OnServerValidate="Accountname_CheckUnique" meta:resourcekey="ACCOUNTNAME_UNAVAILABLE" />
Codebehind so:
protected void Accountname_CheckUnique(object source, ServerValidateEventArgs arguments)
{
arguments.IsValid = Foo();
}
Which was working just fine, and then without changing anything on the page ASP now insists:
No overload for
'Accountname_CheckUnique' matches
delegate 'System.EventHandler'
Well no, and nor should it according to MSDN. It's late and I'm tired, anybody know how to fix this or point out the glaring flaw in my comprehension?
Edit:
I've also tried += binding as an eventhandler in the codebehind and it still requires the EventArgs signature. Makes. No. Sense.
Edit 2:
Deleted and recreated the page entirely (copy paste) and problem went away. Assume some niche thing created a very localised problem.
@MODS: Please close.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许从 Accountname_CheckUnique 方法定义中删除“受保护”?
Maybe remove "protected" from the Accountname_CheckUnique method definition?