TextBox Border Style , Color, Width in ASP.Net

Textbox Border Style in ASP.Net

In our previous post we learnt about textbox font style and this tutorial we will going to learn how to change textbox border style programmatically in asp.net using c#.

List of TextBox border style attributes

Border attributes Description
BorderStyle It is used to define border style.
BorderWidth It is used to define border width.
BorderColor It is used to define border color.

Border Style Properties

TextBox Border Style property used to specify the border style of control.

Border Style Property in ASP.Net C#
Border Style Property in ASP.Net C#

The Border Style property is using with BorderStyle enumeration values.
The below lists are values of BorderStyle.

Border Style Description
Dashed It is used for dashed line border.
Dotted It is used for dotted line border.
Double It is used for solid double line border.
Groove It is used for groove line border.
Inset It is used for Inset line border.
None No Border
NotSet The border style is not set.
Outset It is used for outset border.
Ridge It is used for ridge border.
Solid It is used for solid line border.

TextBox Border Style, Border Width, Border Color Example

Design asp.net web form with three button control along with textbox control. The button control used for change Border style, border color and border with respectively.

Border Style, Color, Width Example ASP.Net
Border Style, Color, Width Example ASP.Net

C# code for above TextBox Border color, with and style asp.net Example

 protected void btnwidth_Click(object sender, EventArgs e)
        TextBox1.BorderWidth = 7;
        Label1.Text = "Border width = 7";
    protected void btnstyle_Click(object sender, EventArgs e)
        TextBox1.BorderStyle = BorderStyle.Double;
        Label1.Text = "Border style = Double";
    protected void btncolor_Click(object sender, EventArgs e)
        TextBox1.BorderColor = System.Drawing.Color.Red;
        Label1.Text = "Border color = Red";


Leave a Reply

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