By default, Visual Studio has been using jQuery, Bootstrap, and JavaScript for over a decade now.
So when you ask "how to use CSS and JavaScript," the options are vast. You can even implement AngularJS or any other modern framework of your choice.
While starting a new Web Forms project may be uncommon nowadays, it's worth noting that Visual Studio defaults to utilizing Bootstrap themes and layouts for more than 10 years. This includes the standard top navigation menu bar.
Let's add a button and an asp.net GridView to demonstrate functionality.
Upon clicking the button, our code will populate the GridView with data.
The standard asp.net controls below lack bootstrap classes:
<asp:Button ID="cmdLoad" runat="server" Text="Show Hotels"
OnClick="cmdLoad_Click"
/>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" >
</asp:GridView>
The code behind to load data is as follows:
Protected Sub cmdLoad_Click(sender As Object, e As EventArgs)
Dim strSQL = "SELECT FirstName, LastName, City HotelName, Description
FROM tblHotelsA ORDER BY HotelName"
GridView1.DataSource = MyRst(strSQL)
GridView1.DataBind()
End Sub
Resulting in a rather basic page appearance like this:
https://i.sstatic.net/bg5Q8.png
Now, let's apply standard bootstrap classes to enhance these controls:
Updated markup:
<asp:Button ID="cmdLoad" runat="server" Text="Show Hotels"
OnClick="cmdLoad_Click"
CssClass="btn"
/>
<br />
<br />
<asp:GridView ID="GridView1" runat="server"
CssClass="table table-striped"
>
</asp:GridView>
We now have a responsive grid and button:
https://i.sstatic.net/IrG0B.png
If you wish to utilize bootstrap info class for the button, simply add:
<asp:Button ID="cmdLoad" runat="server" Text="Show Hotels"
OnClick="cmdLoad_Click"
CssClass="btn btn-info"
/>
The result:
https://i.sstatic.net/batJP.png
Even with asp.net web forms, integrating Bootstrap classes enhances the look and feel. Most controls benefit from these classes or themes.
Feel free to explore using Angular, React, or other newer frameworks with asp.net pages.
Addition of basic bootstrap classes to controls like GridView showcases a significant transformation - making them appear modern and dynamic.
In the provided screenshot, the top application menu bar also utilizes Bootstrap. Even older Web Form templates integrate Bootstrap menu bars by default.
There are minimal limitations in adopting Bootstrap classes for asp.net controls. In most scenarios, these standard Bootstrap classes seamlessly work with asp.net controls.
Similar flexibility applies to incorporating CSS styles within asp.net websites. Users have full freedom to apply various CSS styles as needed.