when I call Page_ClientValidate('Add1') function using javascript, the server controls of asp.net event not working .'Add1' is validation group.
当我使用javascript调用Page_ClientValidate('Add1')函数时,asp.net事件的服务器控件无效.'Add1'是验证组。
1 个解决方案
#1
Please provide some sample code and a better explanation of what you mean by "the server controls of asp.net event not working".
请提供一些示例代码,并通过“asp.net事件的服务器控件无法正常工作”更好地解释您的意思。
In the meantime, here's some sample code of how Page_ClientValidate(validationGroup)
should be used:
与此同时,这里有一些如何使用Page_ClientValidate(validationGroup)的示例代码:
<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>
#1
Please provide some sample code and a better explanation of what you mean by "the server controls of asp.net event not working".
请提供一些示例代码,并通过“asp.net事件的服务器控件无法正常工作”更好地解释您的意思。
In the meantime, here's some sample code of how Page_ClientValidate(validationGroup)
should be used:
与此同时,这里有一些如何使用Page_ClientValidate(validationGroup)的示例代码:
<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>