Change Button border style programmatically
Button is an asp.net web server control. this control render a push button on web page.
button server control have a built in property to set or change its border style programmatically
at run time. button BorderStyle property allow us to do this.
button BorderStyle property get or set the border style of button control. this property value type is System.Web.UI.WebControls.BorderStyle. we can assign BorderStyle property value from one of the BorderStyle enumeration values.
BorderStyle enumeration have many possible values such as NotSet, None, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset etc.
as example BorderStyle enumeration value Dotted display a dotted line border in button server control, Double value display a solid double line in button control.
the following asp.net c# example code demonstrate us how can we apply a border style in button control dynamically at run time.
button BorderStyle property get or set the border style of button control. this property value type is System.Web.UI.WebControls.BorderStyle. we can assign BorderStyle property value from one of the BorderStyle enumeration values.
BorderStyle enumeration have many possible values such as NotSet, None, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset etc.
as example BorderStyle enumeration value Dotted display a dotted line border in button server control, Double value display a solid double line in button control.
the following asp.net c# example code demonstrate us how can we apply a border style in button control dynamically at run time.
ButtonBorderStyle.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button2_Click(object sender, System.EventArgs e)
{
Button1.BorderStyle = BorderStyle.Dotted;
}
protected void Button3_Click(object sender, System.EventArgs e)
{
Button1.BorderStyle = BorderStyle.Dashed;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change Button border style programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">Button Example: BorderStyle</h2>
<asp:Button
ID="Button1"
runat="server"
Text="Test Button BorderStyle"
Font-Bold="true"
BackColor="AliceBlue"
ForeColor="DodgerBlue"
BorderColor="SeaGreen"
/>
<br /><br />
<asp:Button
ID="Button2"
runat="server"
Text="BorderStyle Dotted"
OnClick="Button2_Click"
/>
<asp:Button
ID="Button3"
runat="server"
Text="BorderStyle Dashed"
OnClick="Button3_Click"
/>
</div>
</form>
</body>
</html>



- How to show, hide, visible TextBox programmatically
- How to set, change TextBox width programmatically
- How to set, change TextBox font, text style
- How to set, change Button BackColor (background color)
- How to set, change Button border color programmatically
- How to enable, disable Button programmatically
- How to set, change Button ForeColor (font, text color)