Change TextBox border style programmatically
asp.net textbox server control have a property named BorderStyle. BorderStyle enumeration
have many values such as Dashed, Dotted, Double, Groove, Inset, Outset, Ridge, Solid etc.
by selecting any one of them you can apply specific border style of textbox control. such as if you
use textbox BorderStyle property value Dashed, it will create a dashed border (line with gap) in textbox control.
Dotted BorderStyle property value create a dotted border around textbox control. this example demonstrate how can we
create a styled border around textbox control programmatically.
TextBoxBorderStyle.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.BorderStyle = BorderStyle.Dotted;
}
protected void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.BorderStyle = BorderStyle.Dashed;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change TextBox border style</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">TextBox Example: BorderStyle</h2>
<asp:Label
ID="Label1"
runat="server"
Text="Your Age"
>
</asp:Label>
<asp:TextBox
ID="TextBox1"
runat="server"
BorderColor="Crimson"
>
</asp:TextBox>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="DarkGoldenrod"
Text="TextBox BorderStyle Dotted"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
Font-Bold="true"
ForeColor="DarkGoldenrod"
Text="TextBox BorderStyle Dashed"
OnClick="Button2_Click"
/>
</div>
</form>
</body>
</html>


