asp.net - How to change a Button border color programmatically

Change Button border color programmatically
asp.net button web server control render a push button on web page. we can set or change the button border color by using its built in property. button control's BorderColor property allow us to get or set the button border color programmatically at run time.

button BorderColor property value type is System.Drawing.Color. this property value is a Color that represents the border color of button server control. to assign a border color on button server control we need to import the System.Drawing namespace.

the following asp.net c# example code demonstrate us how can we apply a border color of button server control dynamically at run time in an asp.net application.
ButtonBorderColor.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button2_Click(object sender, System.EventArgs e)
    {
         Button1.BorderColor = System.Drawing.Color.DarkBlue;
    }
    protected void Button3_Click(object sender, System.EventArgs e)
    {
        Button1.BorderColor = System.Drawing.Color.Red;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change Button border color programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">Button Example: BorderColor</h2>
        <asp:Button 
             ID="Button1" 
             runat="server" 
             Text="Test Button BorderColor"
             Font-Bold="true"
             BackColor="Snow"
             ForeColor="Crimson"
             />
        <br /><br />
        <asp:Button 
             ID="Button2" 
             runat="server" 
             Text="BorderColor DarkBlue"
             OnClick="Button2_Click"
             />
        <asp:Button 
             ID="Button3" 
             runat="server" 
             Text="BorderColor Red"
             OnClick="Button3_Click"
             />
    </div>
    </form>
</body>
</html>
Related asp.net example