本文介绍了在ASP.net中使用单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表单中,我有两个单选按钮rdbtn1和rdbtn2
现在当我选择rdbtn1 textbox1 nd textbox2时应禁用(启用textbox3 nd textbox4).当我选择rdbtn2 textbox3 nd textbox4时应禁用(textbox1 nd textbox2启用)

OP的答案移至此处:



我在C#中尝试了相同的逻辑(当我是新开发者plz帮助时)

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)

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无法获得输出..意味着如果我选择任何单选按钮,则不会发生任何更改


bt not getting the output..means if i select any radio button no change is happen

推荐答案

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



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;
}


这篇关于在ASP.net中使用单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 17:31