473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 6064
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.