<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="年龄不能为空!"
ControlToValidate="txtAge" ValidationGroup="patient" Display="Dynamic"></asp:RequiredFieldValidator> <asp:Button ID="btSave" runat="server" class="btn" OnClick="btSave_Click" ValidationGroup="patient"
Text="保 存" OnClientClick="return vrn()" />
同时用ControlToValidate和OnClientClick进行验证时,ControlToValidate就会失效,可以用Page_ClientValidate来解决这个问题。
if (!Page_ClientValidate("patient")) {
return;
}