Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

I am using Asp.net C# , I have one dropdownlist filled with data from database for example A,B,C,D
now i have one radiobutton , what i want is when i click A or D from DropDownlist RadioButton get enable , and when i click B or c radiobutton Get Disable.


please help
Posted
Comments
[no name] 23-Sep-14 1:31am    
show your code and tell us where is your problem
[no name] 23-Sep-14 3:31am    
did you try ? what issue did u face? kindly show your snipset
Member 11014751 23-Sep-14 3:37am    
I have changed my Logic ... Thank you

Hi Assuming that A,B,C,D are DropDown DataTextField Values, You can use this logic.
C#
function DisableRadioButton(obj) {
       var currentDropDownText = obj.options[obj.selectedIndex].text;
       if(currentDropDownText =="A" || currentDropDownText =="D")
       {
          $('#<%=radioId.ClientID%>').attr('disabled', false);
       }
</pre>
 
Share this answer
 
Comments
[no name] 23-Sep-14 1:15am    
Exactly !!
Ajith K Gatty 23-Sep-14 3:55am    
Thank you Praneet :)
Hi,

Did you try doing that using javascript ?

JavaScript
function disableControl(){
   if(document.getElementById('dropdownID').value=="A")
   {
     document.getElementById('radioButtonID').disabled=true;
   }
   else
   {
      document.getElementById('radioButtonID').disabled=false;
   }
  }


I havent tested this code. But this can give you an idea.

Also, check what will be the default selected value for the dropdown.

Regards,
Praneet
 
Share this answer
 
try this ............
<script type="text/javascript">
        function ChangeRdbStatus(ddlvalue)
        {
		var sel = document.getElementById('ddlvalue');
		var selText = sel.options[sel.selectedIndex].text;

            switch(selText)
            {
                case 'A':
 			document.getElementById('radiobuttonName').setAttribute('disabled','disabled');
                   	break;
               	case 'B':
                    document.getElementById('radiobuttonName').removeAttribute('disabled');    
                    break;
                case 'C':
                    document.getElementById('radiobuttonName').removeAttribute('disabled');    
                    break;
		case 'D':
 		   document.getElementById('radiobuttonName').setAttribute('disabled','disabled');
                    break;	
            }
        }
</script>

<asp:dropdownlist id="SelectOrg" runat="server" onclick="ChangeRdbStatus(this)" xmlns:asp="#unknown"></asp:dropdownlist></script>
 
Share this answer
 
Comments
Member 11014751 23-Sep-14 3:50am    
Ok Thanks Let me Check

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900