disable radio button in RadioButtonList

G

Guest

Is it possible to disable just a certain radio button in
a RadioButtonList control? I've researched this issue for
a while now and haven't come up with anything.

Thanks,
Dave
 
A

alex bowers

Hi Dave
this is possible by amending the html the browser emits
to represent the option buttons through client-side
javascript.

First, Add some script to your page:
function disableoption(control,option)
{
var formObj = document.forms[0];
for (i=0;i<formObj.length;i++)
{
fldObj = formObj.elements;
if (fldObj.type == 'radio')
{
var name = control + '_' + option;
if (fldObj.id == name)
fldObj.disabled = true;
}}}

You can then call this script from the server side,
programmatically entering the name of your control and
the index of the item you wish to disable, eg
Page.RegisterStartupScript("disablescript","<SCRIPT
language='javascript'>disableoption
('RadioButtonList2','1');</SCRIPT>");

alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top