How to set, change TextBox height programmatically
asp.net textbox web server control Height property help you to manage textbox height at runtime.
we can change the textbox height programmatically by asigning it's Height property value. Height
property only accept numeric value. asp.net developers change textbox height for better user experience
or make a exact readable textbox for higher font size. this example show you how can we set or change textbox
height programmatically.
TextBoxHeight.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.Height = 25;
}
protected void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Height = 50;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change TextBox height programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Red">TextBox Example: Height</h2>
<asp:Label
ID="Label1"
runat="server"
Text="Favorite Flower"
>
</asp:Label>
<asp:TextBox
ID="TextBox1"
runat="server"
BackColor="LightPink"
>
</asp:TextBox>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="DodgerBlue"
Text="TextBox Height 25"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
Font-Bold="true"
ForeColor="DodgerBlue"
Text="TextBox Height 50"
OnClick="Button2_Click"
/>
</div>
</form>
</body>
</html>
- How to set, change Label font name programmatically
- How to set, change TextBox border style
- How to set, change TextBox font size
- How to set, change TextBox ForeColor (font, text color)
- How to convert TextBox TextMode SingleLine to MultiLine
- How to convert, change TextBox TextMode SingleLine to Password
- How to use theme and skin in TextBox