How to visible TextBox programmatically in ASP.NET

How to visible / Hide  TextBox in ASP.Net C#

- Hi, Here we are going to learn , How to TextBox Control Visible and Hide OR Visible True/False  in ASP,.Net C#.

- First we have to Design the ASP.Net Page with One TextBox Control along with Two (2) Button  Control.
- The ASP.Net Design Code is below :

write below code in Head tag:-

    <form id=”form1″ runat=”server”>
<table style=”width: 304px”>
                            <td style=”width: 100px; text-align: right”>
                                TextBox :</td>
                            <td colspan=”2″ style=”text-align: left”>
                                <asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox></td>
                            <td style=”width: 100px; height: 26px”>
                            <td colspan=”2″ style=”height: 26px; text-align: left”>
                                &nbsp;<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”Visible” />
                                <asp:Button ID=”Button2″ runat=”server” OnClick=”Button2_Click” Text=”Hide” Width=”48px” /></td>

write below code for visible TextBox Control:-

protected void Button1_Click(object sender, EventArgs e)
        TextBox1.Visible = true;

- In below figure we can see the Texbox Control as we clicked Visible Button.

- Visible Property = True;

Write below code for Hide/Invisible TextBox:-

protected void Button2_Click(object sender, EventArgs e)
        TextBox1.Visible = false;

- In below figure can not see the TextBox Control on webform as we clicked Hide Button.

- Visible Property = False;

TextBox Invisible in ASP.Net

TextBox Invisible in ASP.Net

- Here, We learnt programmatically Change the TextBox Visible True and False.
- The same things we can do without programmatically like this:
Just SET the TextBox Visible Property Visible  = True/ False  for Visible / Hide the TextBox Control.

- I hope, you will enjoy this  ASP.Net TextBox Example of  Visible True/False of TextBox Control.

Leave a Reply

Your email address will not be published. Required fields are marked *

9 + 3 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">