Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CustomValidator not working in FormView

Reply
Thread Tools

CustomValidator not working in FormView

 
 
J. Cairn
Guest
Posts: n/a
 
      09-16-2007
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?

 
Reply With Quote
 
 
 
 
Forum
Guest
Posts: n/a
 
      09-20-2007
Hi, tested and it seems fine, can you provide more code?


"J. Cairn" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) 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?
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CustomValidator on CheckBox not working theresa ASP .Net 2 09-12-2007 05:02 PM
CustomValidator not working in FireFox Glen ASP .Net Web Controls 3 06-29-2006 07:58 AM
customvalidator using clientside script in FormView Dabbler ASP .Net Web Services 0 04-13-2006 03:43 AM
Server side CustomValidator and FormView Mo ASP .Net Web Controls 0 03-02-2005 09:01 PM
CustomValidator not working tshad ASP .Net 4 11-12-2004 05:04 PM



Advertisments