when i calling Page_ClientValidate('Add1') function using javascript, the server controls of asp.net event not working .'Add1' is validation group.
views:
104answers:
1
+1
A:
Please provide some sample code and a better explanation of what you mean by "the server controls of asp.net event not working".
In the meantime, here's some sample code of how Page_ClientValidate(validationGroup)
should be used:
<asp:TextBox runat="server" ID="tbHours" Width="50px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rvalAddHours" runat="server" ControlToValidate="tbHours" ValidationGroup="AddEntry" ErrorMessage="* Hours Required" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="rgValAddHours" runat="server" ControlToValidate="tbHours" ValidationGroup="AddEntry" ErrorMessage="* Hours Must Be 0-24" Display="Dynamic" Type="Double" MinimumValue="0" MaximumValue="24"></asp:RangeValidator>
<asp:Button ID="btnAddEntry" runat="server" OnClientClick="ValidateAndAddNewEntry(); return false;" CausesValidation="true" ValidationGroup="AddEntry" Text="Create" />
<script type="text/javascript>
function ValidateAndAddNewEntry() {
var res = Page_ClientValidate("AddEntry");
if ( res == true ) {
//Do work
}
}
</script>
Jose Basilio
2009-06-01 06:04:50