Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling item in a checkboxlist

Status
Not open for further replies.

maboo59

Programmer
Mar 21, 2005
18
US
How can I disable items in a checkboxlist when page loads in the codebehind?
The list is created in the .aspx file and when user selects from a dropdownlist and page is submitted cerainn listitems are disabled based on users selection. But I don't know how to reference the items individually.
Mab0059
 
I am not sure that to disabke some items can be achived. You can though create some arraylist and addrage to them the items you need.
Then depending on the dropdown selected item you should populate the checklistbox with one arraylist.



-bclt
 
disabke = disable
addrage = addrange

And: the array list can be created not only at run time; mean when page is loaded to the user. {"1", "2", .. "n"}



-bclt
 
ca8msm,
Thanks alot, that was what I needed. I made some modifications to fit what I need. When user selects a from a dropdownlist and the page submits, I determine which boxes I need to disable and assign to a hidden tag the index of the first box to disable. Then on the aspx side I call the below javascript function to disable the correct boxes:
function disableMonths(){
objCtrl = document.getElementById('monthChk');
if(objCtrl == null)
{
return;
}
var i = 0;
var objItem = null;
var objItemChecked = document.getElementById('monthChk' + '_' + firstDisMonth.value);
if(objItemChecked == null)
{
return;
}
for(i = firstDisMonth.value; i < 12; i++)
{
objItem = document.getElementById('monthChk' + '_' + i);
if(objItem == null)
{
continue;
}
objItem.disabled = true;
}
}

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top