Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

CustomValidator on CheckBox not working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
theresa - 12 Sep 2007 16:26 GMT
I'm about at my wits end trying to figure out why this isn't working,
so I'm hoping one of you can help! I'm sure there must be something
simple I'm missing.

I have a checkbox on an Asp.NET 2.0 web form that needs to be checked
before the form is successfully submitted. I've done the same thing on
an Asp.NET 1.1 form before and had no problems, but using the exact
same code on the 2.0 form absolutely nothing happens. No errors of any
kind (not even Javascript) and it acts the same in both Firefox and
IE. I've tried adding various test statements to the server-side
validation function (as indicated in the commented out code below),
but even those don't appear. I should add that all of the
RequiredFieldValidators on the page work just fine. Code below. Any
help is most appreciated!

<asp:CheckBox ID="chkStatement" runat="server" TextAlign="right" />

<asp:CustomValidator runat="server" id="custStatement"
OnServerValidate="reqStatement" ErrorMessage="* You must check the
checkbox."
Font-Bold="true" Font-Size="15" ForeColor="#FF0000" Display="dynamic"
> ! </asp:CustomValidator>

'require the statement be checked before submission
Sub reqStatement(sender as Object, args as ServerValidateEventArgs)

    args.IsValid = chkStatement.Checked
    'response.write("reqStatement fired") [does nothing]
    'args.IsValid = False [also does nothing]

End Sub
bruce barker - 12 Sep 2007 16:35 GMT
you did not supply a client function, so no javascript is generated.
does you server code call Page.IsValid or Page.Validate(), so that
server validation is run?

-- bruce (sqlwork.com)

> I'm about at my wits end trying to figure out why this isn't working,
> so I'm hoping one of you can help! I'm sure there must be something
[quoted text clipped - 27 lines]
>
> End Sub
theresa - 12 Sep 2007 18:02 GMT
Hi Bruce -

Thanks for your reply! I didn't supply a client function because I was
trying to use server-side validation. However, as soon as I added a
client validation function, the server-side validator started working!
Odd, and I'm thinking perhaps Microsoft should have mentioned that in
their documentation somewhere. Anyway, thanks for your help! I'm so
glad to have this finally resolved.

> you did not supply a client function, so no javascript is generated.
> does you server code call Page.IsValid or Page.Validate(), so that
[quoted text clipped - 33 lines]
>
> > End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.