Using Bootstrap in our ASP.NET Website application can make our web application responsive and make UI look more redefined and attractive to our users. Bootstrap is an open source toolkit for developing with HTML, CSS, and JS. So, let’s design ASP.NET Buttons using Bootstrap CSS.
Step 1 : Reference the Bootstrap StyleSheet in inside “<head>” tag of your ASP.NET page :
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" >
Step 2 :
Reference the CssClass property of your ASP.NET Button like :
<asp:Button runat="server" Text="btn-primary" CssClass="btn btn-primary" />
More Examples :
<div class="col-lg-10"> <asp:Button runat="server" Text="btn-primary" CssClass="btn btn-primary" /> <asp:Button ID="Button1" runat="server" Text="btn-sucess" CssClass="btn btn-success" /> <asp:Button ID="Button3" runat="server" Text="btn-danger" CssClass="btn btn-danger" /> <asp:Button ID="Button4" runat="server" Text="btn-warning" CssClass="btn btn-warning" /> <asp:Button runat="server" Text="btn-info" CssClass="btn btn-info" /> <asp:Button runat="server" Text="btn-dark" CssClass="btn btn-dark" /> <asp:Button runat="server" Text="btn-default" CssClass="btn btn-default" /> <asp:Button runat="server" Text="btn-group" CssClass="btn btn-group" /> </div>
Full Code :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Index" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>BootStrap Buttons in ASP.NET</title> <link href="css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <form id="form1" runat="server"> <div class="row" style="padding: 5px"> <h1>ASP.NET Button CSS - Using Bootstrap Styling</h1> </div> <div class="row" style="padding: 5px"> <div class="col-lg-10"> <asp:Button runat="server" Text="btn-primary" CssClass="btn btn-primary" /> <asp:Button ID="Button1" runat="server" Text="btn-sucess" CssClass="btn btn-success" /> <asp:Button ID="Button3" runat="server" Text="btn-danger" CssClass="btn btn-danger" /> <asp:Button ID="Button4" runat="server" Text="btn-warning" CssClass="btn btn-warning" /> <asp:Button runat="server" Text="btn-info" CssClass="btn btn-info" /> <asp:Button runat="server" Text="btn-dark" CssClass="btn btn-dark" /> <asp:Button runat="server" Text="btn-default" CssClass="btn btn-default" /> <asp:Button runat="server" Text="btn-group" CssClass="btn btn-group" /> </div> <br /> <br /> <div class="col-lg-10"> <asp:Button ID="Button2" runat="server" Text="btn-block" CssClass="btn btn-block" /> </div> </div> </form> </body> </html>
Output :