带有母版页按钮单击的自定义验证器
我在内容页面中有一个自定义验证器
<asp:CustomValidator id="CustomValidator1" runat="server"
OnServerValidate="RevisionValidate"
ControlToValidate="TextBoxRevisionOrder"
ErrorMessage="Invalid RevOrder Format">
</asp:CustomValidator>
,其中 RevisionValidate 是服务器端方法
protected void RevisionValidate(object source, ServerValidateEventArgs args)
{
//Code goes here
if (CurrentRevisionOrder != "-1" && ChangedRevisionOrder == "-1")
{
val = "Not Valid";
}
else
{
val = "Valid";
}
args.IsValid = (val == "Valid");
}
自定义验证器在内容页面按钮单击时完美触发,但问题是我在母版页中也有一个自定义验证器需要触发的按钮。用我当前的代码它是单击母版页按钮时未触发。有任何帮助吗?
i have a custom validator in a content page
<asp:CustomValidator id="CustomValidator1" runat="server"
OnServerValidate="RevisionValidate"
ControlToValidate="TextBoxRevisionOrder"
ErrorMessage="Invalid RevOrder Format">
</asp:CustomValidator>
where RevisionValidate is a serverside method
protected void RevisionValidate(object source, ServerValidateEventArgs args)
{
//Code goes here
if (CurrentRevisionOrder != "-1" && ChangedRevisionOrder == "-1")
{
val = "Not Valid";
}
else
{
val = "Valid";
}
args.IsValid = (val == "Valid");
}
Custom validator fires perfectly on content page button click but the issue is i also have a button in the master page which the custom validator need to fire.with my current code it's not firing on master page button click.any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在母版页中的按钮上使用
ValidationGroup
属性。内容页:
母版页:
Try using
ValidationGroup
property on button in master page.Content Page:
Master Page:
找到了解决方案。我必须检查一下
Found the solution. I had to check