disable radio button in RadioButtonList

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top