472,961 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

CustomValidator on CheckBox not working

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

Sep 12 '07 #1
1 6022
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)
theresa wrote:
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
Sep 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Gene McCrory | last post by:
Is it possible to have a CustomValidator against two controls in an EditItemTemplate on a DataGrid? Case: Have a business rule that states if ATextBox starts with "ACertainValue" then BTextBox...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
1
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
1
by: Nathan Sokalski | last post by:
I want to make sure that the SelectedDate property of the Calendar control is later than the current date or that a certain checkbox is selected. I tried to use a CustomValidator control with the...
3
by: Jaime Stuardo | last post by:
Hi all... I'm trying to use a custom validator for a group of checkboxes in order to validate that at least 1 checkbox is checked before submitting the form. I placed 2 checkbox controls in...
1
by: avp | last post by:
Hi, We have an ASP.NET 2.0 (C#) application that has a web form with a CheckBoxList control and a CustomValidator control. The CustomValidator control is used to validate that at least one...
1
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address...
0
by: RichardH | last post by:
Hi, I have a Repeater where each row (Repeater item) contains a Checkbox and two Textboxes. The first Textbox has a RequiredFieldValidator and everything work fine. The other should only...
0
by: pompeymike | last post by:
Hi, I have a form with panels, within which is a Formview. In the InsertItemTemplate for the FormView I have validation using RequireFieldValidators. These all work correctly, but if I use a...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.