473,607 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript">

function ChkMusicTasteSe lection(source, arguments) {

var t = 0;

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

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

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

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

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

arguments.IsVal id = true;
}
else {
arguments.IsVal id = false
}
}
}

</script>

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

...
<TD style="HEIGHT: 188px"><asp:che ckboxlist 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:64 0px;">
<tr>
<td><input id="musicTaste_ 0" type="checkbox" name="musicTast e:0"
/><label for="musicTaste _0">60's</label></td>
<td><input id="musicTaste_ 1" type="checkbox" name="musicTast e:1"
/><label for="musicTaste _1">70's</label></td>
<td><input id="musicTaste_ 2" type="checkbox" name="musicTast e:2"
/><label for="musicTaste _2">80's</label></td>

...
Jul 23 '05 #1
1 3229
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
790
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 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.
9
5145
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 have other code within the customvalidator which works). This won’t work (within servervalidate): If txtBox.Text.ToString = "" Then raise exception…..
3
6336
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 ControlToValidate property of 'ServiceTypesCheck' cannot be validated <asp:CheckBoxList id="RFPServiceTypes" CellPadding="0" CellSpacing="0"
0
2135
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 one of my ASP.NET 1.1 web forms. This involves a fairly simple inheritance of the System.Web.UI.WebControls.RadioButtonList class, with some new properties added and the Render sub overridden. When I come to render each radio item, I do the...
3
1173
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 they checked "not so great" or "awful", comments would be required before allowing the page to post.
3
3178
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 I would like to show a checkboxlist within my formview to represent them. I just have no idea how to bind this collection to a list within the formview? Has anyone got any ideas on this? I don't need the full code, just a pointer in the right...
0
1340
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 checkboxes and post the form. In .NET 1.1 it worked as expected: when control's state was set to enable - the selected checkboxes had their Selected property set to true. However in ..NET 2.0 this does not work - althought Request.Form collection...
15
6504
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
4
2099
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 required validator. I need to have a validator for my custom control, but don't know how to do this. I added a CustomValidator to the form, but in design mode, my custom
0
7987
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8472
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8464
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8324
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6805
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3954
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2464
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1318
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.