Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
In my form I am having two radionbutton rdbtn1 and rdbtn2
now when I select rdbtn1 textbox1 nd textbox2 should be disabled (textbox3 nd textbox4 enabled).and when I select rdbtn2 textbox3 nd textbox4 should be disabled ( textbox1 nd textbox2 enabled)

OPs answer moved to here:

Hi ,

I tried the same logic in C# (As i m new developer plz help)
C#
protected void rbtnParent_CheckedChanged(object sender, EventArgs e)
{
   txtChildRouteList.Enabled = false;
   btnAdd.Enabled = false;
   btnDelete.Enabled = false;
   lstbxChildRoute.Enabled = false;
   Panel1.Enabled = false;
 
   drpdwnOrigin.Enabled = true;
   drpdwnDest.Enabled = true;
}

bt not getting the output..means if i select any radio button no change is happen
Posted
Updated 5-Jul-11 16:55pm
v3
Comments
Prerak Patel 5-Jul-11 6:07am    
Why don't you try something first? Is it that tough?
Shahriar Iqbal Chowdhury/Galib 5-Jul-11 6:23am    
share with us what you did so far?

First of all you must set the same group property to both your radiobuttons 

select the radiobutton and go to property set the group property something like"a"

select the other radiobutton and set the same property "a"

Now your radiobuttons will not checked together.

Protected Sub rdbtn1_CheckedChanged(sender As Object, e As EventArgs) Handles radShowInvoiceTotal.CheckedChanged

            textbox1 .Enabled = True
            textbox2 .Enabled = True
            textbox3 .Enabled = False
            textbox4 .Enabled = False
  
End Sub


Protected Sub rdbtn2_CheckedChanged(sender As Object, e As EventArgs) Handles radShowInvoiceTotal.CheckedChanged
 
            textbox1 .Enabled = False
            textbox2 .Enabled = False
            textbox3 .Enabled = True
            textbox4 .Enabled = True


End Sub
 
Share this answer
 
v2
You can do this with a little javascript that responds to the onclick event of the radiobutton in question. That way you don't have to postback on every click.
 
Share this answer
 
Do it using Javascript, it will improve your code performance.

look following example
if(document.getElementById("CHK1").checked)
{
   document.getElementById("TEXTBOX1").disabled = false;
   document.getElementById("TEXTBOX2").disabled = false;
   document.getElementById("TEXTBOX3").disabled = true;
   document.getElementById("TEXTBOX4").disabled = true;
}
 
Share this answer
 

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