RTT Posted March 31, 2005 Posted March 31, 2005 It's my first time i want to write a cotum validator but it doesn't seem to work. In de page i've put this validator: <asp:CustomValidator id="CVFBeginDate" OnServerValidate="CVFBeginDate_ServerValidate" runat="server" ErrorMessage="Please fill in a valid date as startdate" ControlToValidate="TxtBeginDate">*</asp:CustomValidator> in de codebehindpage i have created this sub: Protected Sub CVFBeginDate_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CVFBeginDate.ServerValidate Try tmp = args.Value.Split("/") testDate = New Date(tmp(2).ToString(), tmp(1).ToString(), tmp(0).ToString()) args.IsValid = True Catch args.IsValid = False End Try End Sub it doesn't seem to work. do you have to put something special to the custom validator? Quote
wessamzeidan Posted March 31, 2005 Posted March 31, 2005 You have to check for Page.IsValid, which will tell you if the result of executing the validation function was true or false Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
RTT Posted March 31, 2005 Author Posted March 31, 2005 thxs... that solved the problem indeed... didn't know u had to use that to trigger validation.. thxs Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.