473,382 Members | 1,814 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,382 software developers and data experts.

checkbox validation

I posted this this morning but it never went through, so I am trying
again -- apologies for the duplication if so.

I need to validate several checkboxes on an asp.net 2.0 page. I don't
need to validate that they are checked; instead, I am trying to
prevent potential SQL or code injection via checkbox controls. These
checkboxes are inside a formview.

I found examples (e.g at http://msdn2.microsoft.com/en-us/library/aa479013.aspx)
of how to validate that at least one in a group of checkboxes, or one
of a checkboxlist, has been checked, but my requirement is a little
different.

What I'd like to do is write a server side and client side functions
that several customvalidation controls can share. So the function
would determine which checkbox control is failing validation and
respond appropriately.

The example code looks like this:

<script runat="server">

Sub CustomValidator1_ServerValidate(source As Object, _
args As ServerValidateEventArgs)

args.IsValid = (CheckBox1.Checked = True)
End Sub

Sub Button1_Click(sender As Object, e As EventArgs)
If Page.IsValid Then
Label1.Text = "Thank you for your donation!"
Else
Label1.Text = ""
End If
End Sub

</script>
....
<asp:CheckBox id="CheckBox1" runat="server"
Text="Donate $10"></asp:CheckBox>
&nbsp;
<asp:CustomValidator id="CustomValidator1"
runat="server" ErrorMessage="Please donate $10"
OnServerValidate="CustomValidator1_ServerValidate" >
</asp:CustomValidator>

The problem is that the checkbox control is referenced in Sub
CustomValidator1_ServerValidate by its ID, but I'd like the server
side validation subroutine to handle any number of different
checkboxes.

Is it possible to determine which checkbox is failing validation by
examining either of the two parameters passed to Sub
CustomValidator1_ServerValidate? (either "source" or
"ServerValidateEventArgs")?

Thanks.

-- Ned Balzer
Dec 19 '07 #1
0 2250

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

Similar topics

2
by: Czarina | last post by:
hi guys! here I am again, bugging you Here is where my page stands right now: http://www.gainesvillewebs.com/czar...h_results-2.htm The top 2 forms are working just fine, but the bottom one, with...
3
by: Earl Teigrob | last post by:
I wanted my "Terms and Conditions" Checkbox control to participate in my ASP.NET validation just like all the the other controls on the page. After some time of searching the web for an example of...
2
by: Asha | last post by:
greetings i want to use the required field validator control to validate a checkbox. here is the code implemented. <asp:RequiredFieldValidator ID="rfv" ControlToValidate="chkDistiAudit"...
5
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
5
by: nescio | last post by:
hello, i am making a form using php/html/javascript a part of the form is (email address) comming from a database. the amount of addresses is always different. every address has a checkbox....
7
by: karen987 | last post by:
The code below is for a checkbox, in a form on an asp page. I want to make it mandatory for the user to click it. The other validation statements work fine, this one causes a problem though. The...
12
by: tadisaus2 | last post by:
Hello, Checkbox form validation - how to make a user select 4 check boxes? I have a question of a few checkboxes and how do I require a user to check 2 checkboxes (no more, no less)? Here is my...
1
by: sureshl | last post by:
Error in client side validation object expected error in this line,--> OnClientClick="return validation1(<%=maxnumber %>); Syntax error : in this line :for(i=0;i<maxno;i++) i want to validate...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.