Make a textbox visible by selecting a radiobutton

1

With the code below I can do this procedure however I have to click the button. It looks like 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;
}
    
asked by anonymous 09.08.2017 / 15:32

1 answer

1

You can use the AutoPostBack property 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 through the% cos_de% of visual studio window.

But I think it's best to do it by javascript, which avoids postback.

    
09.08.2017 / 15:47