customvalidator

ASP.NET Custom Validator Client side & Server Side validation not firing

≡放荡痞女 提交于 2019-11-27 09:43:31
问题 This has not happened to me before, but for some reason both the client and server side validation events are not being triggered: <asp:TextBox ID="TextBoxDTownCity" runat="server" CssClass="contactfield" /> <asp:CustomValidator ID="CustomValidator2" runat="server" EnableClientScript="true" ErrorMessage="Delivery Town or City required" ClientValidationFunction="TextBoxDTownCityClient" ControlToValidate="TextBoxDTownCity" OnServerValidate="TextBoxDTownCity_Validate" Display="Dynamic" > </asp

How to get the 'controlToValidate' property on ClientValidationFunction?

此生再无相见时 提交于 2019-11-27 05:51:37
问题 Lets say I have this code. <asp:TextBox ID="TextBox1" runat="server" /> <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidationFunction1" ControlToValidate="TextBox1" Display="Dynamic" /> And a validationFunction: function ValidationFunction1(sender, args) { } And i would like to know if, inside the function I could get the Control to validate something like: var v = sender.ControlToValidate; 回答1: Actually sender.controltovalidate gives the ClientID of