473,326 Members | 2,010 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,326 software developers and data experts.

Custom Validator for a checkboxlist control – Strange behavior.

I am attempting to create an ASP.NET Custom Validator javascript for a
checkboxlist control. My goal is to limit the total number of
selections to be 1 - 5 at most. My problem is that I get a null
reference when I attempt to retrieve an object for an individual list
item, which of course results
in an "object required" error message.

Anyone know what to do? tnx in advance

-Itai.

Here is the code:
<HEAD>

....
<script language="JavaScript">

function ChkMusicTasteSelection(source, arguments) {

var t = 0;

for(var i = 0; i < 31; i++) {

var chkbx = document.all.item("musicTaste_" + i);

// document.write(chkbx) --> null (getElementById() produces the
same effect)

if(chkbx.checked == true){
t++;
}
}

if((t <= 5) && (t >= 1)) {

arguments.IsValid = true;
}
else {
arguments.IsValid = false
}
}
}

</script>

</HEAD>
<body>
<form id="Form1" method="post" runat="server">

...
<TD style="HEIGHT: 188px"><asp:checkboxlist id="musicTaste"
runat="server"
Width="640px" RepeatColumns="5" RepeatDirection="Horizontal">

<asp:ListItem Value="1">60's</asp:ListItem>
<asp:ListItem Value="2">70's</asp:ListItem>
<asp:ListItem Value="3">80's</asp:ListItem>

...


Rendered Output: (browser ie6sp1)
<TD style="HEIGHT: 188px"><table id="musicTaste" border="0"
style="width:640px;">
<tr>
<td><input id="musicTaste_0" type="checkbox" name="musicTaste:0"
/><label for="musicTaste_0">60's</label></td>
<td><input id="musicTaste_1" type="checkbox" name="musicTaste:1"
/><label for="musicTaste_1">70's</label></td>
<td><input id="musicTaste_2" type="checkbox" name="musicTaste:2"
/><label for="musicTaste_2">80's</label></td>

...
Jul 23 '05 #1
1 3204
On 18 Jul 2004 07:32:33 -0700, Itai wrote:
My problem is that I get a null
reference when I attempt to retrieve an object for an individual list
item, which of course results
in an "object required" error message.
I did not experience the same problem when I
failed to visit the URL you did not supply.

I cannot see what you are on about.
Anyone know what to do?


Give URL. ;-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #2

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

Similar topics

2
by: Itai | last post by:
I am attempting to create an ASP.NET Custom Validator javascript for a checkboxlist control. My goal is to limit the total number of selections to be 1 - 5 at most. My problem is that I get a null...
9
by: Alex Shirley | last post by:
Hi there I’m simply trying to check for a blank or empty value in a textbox on my webform. In this instance I do not want to use a requiredfieldvalidator, I want to use a customvalidator (as I...
3
by: tshad | last post by:
Can you use a Required Validator on a CheckBoxList? You can on a RadioButtonList. But when I try on my CheckBoxList I get the error: Control 'RFPServiceTypes' referenced by the...
0
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
3
by: Mike Collins | last post by:
If possible, how can I use a custom validator to check (client side) that if a certain value was checked in a checkboxlist? So, if they checked "great" or "good", comments are not required and if...
3
by: cannontrodder | last post by:
I am displaying names and other details of my users in a Formview control by binding my custom business object to it. My custom object also has a property that is a collection of boolean values and...
0
by: Piotr Strycharz | last post by:
Hi, Here is my situation: I have disabled CheckBoxList. This CheckBoxList (actually: all of the checkboxes) is being enabled by user using javascript code. Than - user can select some of the...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
4
by: Rick | last post by:
Hello, I built a composite web control that has a textbox and a date control. added my custom control on a webform where there are other standard controls. Each control on the form has a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.