i have a checkbox which is in a usercontrol and the usercontrol is in an wizardcontrol and the wizardcontrol is on a content page which has a master开发者_开发百科page.
the checkbox must be checked before the wizard controls finishes. the checkbox and the customvalidator are on the last step of the wizardcontrol.
now everything works fine with firefox and when i test it also with ie. but somehow other people may be able to go on with the proces without having to check the checkbox. the checkbox also has a togglebutton extender. i hope that that is not a problem.
my inline javascript (in the usercontrol)
<script language="javascript" type="text/javascript">
// <![CDATA[
function ValidateTandCs(source, args)
{
args.IsValid = document.getElementById('<%= cbAV.ClientID %>').checked;
}
// ]]>
</script>
the checkbox:
<asp:checkbox id="cbAV" runat="server"/>
the customevalidator and togglebutton extender
<asp:CustomValidator
ID="rfvAV"
Display="Dynamic"
runat="server"
ControlToValidate="cbAV"
ErrorMessage="RequiredFieldValidator"
ClientValidationFunction="ValidateTandCs"
onservervalidate="rfvAV_ServerValidate">
</asp:CustomValidator>
<ajaxToolkit:ToggleButtonExtender
ID="tbeav"
runat="server"
TargetControlID="cbAV"
ImageHeight="15"
ImageWidth="15"
CheckedImageUrl="~/images/checkbox-on.gif"
UncheckedImageUrl="~/images/checkbox-off.gif" />
the code behind of the customvalidator
protected void rfvAV_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = (cbAV.Checked);
}
i have tried to remove the clientside validation from the customvalidator, but when i only have the server validation. it doesn't work
Why are you using both a validation routine on the client side and one on the server side?
Try removing the ClientValidationFunction property on your and keep the OnServerValidate property.
found the problem. it was that the javascript (clientside) didn't work in IE. the serverside validation, validated really good. but when you click on the finishbutton of the wizard control it didn't had a page.isvalid check. so it just ignored the invalid validator. my bad.
精彩评论