Make a textbox visible by selecting a radio button

Asked

Viewed 199 times

1

With the code below I can do this procedure but I have to click the button. It seems that it needs a refresh to work

<asp:RadioButton ID="RadioButton1" runat="server" GroupName="pesquisa" /> Teste
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="pesquisa"/> Teste2
<asp:TextBox ID="TextBox1" runat="server" Visible="false"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />

C#:

if (RadioButton1.Checked == true)
{
    TextBox1.Visible = true;
}
  • I would use javascript for that

  • Okay, thanks for the tip, buddy.

1 answer

1


You can use the property AutoPostBack for the page to process changes:

AutoPostBack="True"

<asp:RadioButton ID="RadioButton1" runat="server" GroupName="pesquisa" AutoPostBack="True" /> Teste

It is also possible to change by window Properties of visual studio.

But, I believe that the recommended is to do by javascript, which avoids postback.

  • Perfect Rovann, thank you very much.

  • for nothing, have =]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.