Hi, tested and it seems fine, can you provide more code?
"J. Cairn" <> schreef in bericht
news: s.com...
>I have tried everything and can't get the validation code to fire.
> Code is below. I have simplified some of it to test it.
>
>
> Here is the CustomValidator (it is in the InsertItemTemplate of my
> FormView):
> -----------------------------------------------------------------------------------------------------------------------------------------------
> <asp:CustomValidator ID="CustomValidator1" runat="server"
> ControlToValidate="DropDownList2"
> ErrorMessage="You must make a lunch choice." ValidateEmptyText="True"
> OnServerValidate="ValidatorTest_ServerValidate"></
> asp:CustomValidator></td>
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
>
> Here is the custom validation code. For testing, I set it to
> automatically "fail".
> -----------------------------------------------------------------------------------------------------------------------------------------------
> Sub ValidatorTest_ServerValidate(ByVal sender As Object, ByVal
> args As ServerValidateEventArgs)
> args.IsValid = False
> End Sub
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
>
> Here is the code on the Submit button.
> -----------------------------------------------------------------------------------------------------------------------------------------------
> Sub btnSubmit_Click(sender as Object, e as EventArgs)
> If Page.IsValid then
> Response.Write("Page is valid")
> Else
> Response.Write("Page is not valid.")
> End If
> End Sub
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
> When I run the page, I get a message saying "Page is valid" which
> would indicate that the validation code is not even running. What am I
> doing wrong?
>
|