Hide and visible TextBox programmatically
this tutorial help you to understand TextBox control's visibility feature. here we demonstrate
how to hide or show textbox control programmatically. asp.net textbox web server control Visible
property have two possible value (enumeration) True and False. if you set the textbox
Visible property value false then textbox will be hidden from web page. so that if you set the Visible
property value true it will make visible the hidden textbox in web page. in this example you can show or hide
textbox programmatically by button click event.
TextBoxVisible.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.Visible = false;
}
protected void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Visible = true;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to show, hide, visible TextBox programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Fuchsia">TextBox Example: Hide, Visible</h2>
<asp:Label
ID="Label1"
runat="server"
Text="Favorite Dress"
>
</asp:Label>
<asp:TextBox
ID="TextBox1"
runat="server"
>
</asp:TextBox>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="MediumPurple"
Text="Hide TextBox"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
Font-Bold="true"
ForeColor="MediumPurple"
Text="Visible TextBox"
OnClick="Button2_Click"
/>
</div>
</form>
</body>
</html>

