Introduction
CSS means Cascading Style Sheet. The World Wide Web Consortium (W3C) created CSS. CSS describes the style of an HTML document.
CSS describes how HTML elements should be displayed.
Description
External stylesheets are stored in CSS files. CSS is used to define the styles for your Web pages, which includes the design, layout and the variations in display for the different devices and the screen sizes.
Steps
Part1
Create a CSS file named Styles.css.
- body {
- font-family: Arial;
- }
-
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 70%;
- }
-
- .button {
- background-color: #4CAF50;
- border: none;
- color: white;
- padding: 15px 32px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 14px;
- margin: 4px 2px;
- cursor: pointer;
- }
-
- .button4 {border-radius: 14px;}
-
- .textbox {
- height: 50px;
- padding: 0 10px;
- border: none;
- background: Orange;
- background: Orange;
- box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5);
- font-family: 'Montserrat', sans-serif;
- text-indent: 10px;
- color: blue;
- text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
- font-size: 20px;
- width: 470px;
- }
- .textbox:focus {
- box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 255, 255, 0.15);
- outline: none;
- background: Orange;
- background: Orange;
- outline: solid 1px yellow;
- }
Description of Part1To apply design and layout to ASP.NET button controls, the button background color should be Green and the text on button should be White.
- .button {
- background-color: #4CAF50;
- border: none;
- color: white;
- padding: 15px 32px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 14px;
- margin: 4px 2px;
- cursor: pointer;
- }
-
- .button4 {border-radius: 14px;}
For table design and layout, the table width should be 70%.
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 70%;
- }
For textbox design and layout, the textbox background color is Orange and Text is in blue.
- .textbox {
- height: 50px;
- padding: 0 10px;
- border: none;
- background: Orange;
- background: Orange;
- box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.5);
- font-family: 'Montserrat', sans-serif;
- text-indent: 10px;
- color: blue;
- text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
- font-size: 20px;
- width: 470px;
- }
- .textbox:focus {
- box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 255, 255, 0.15);
- outline: none;
- background: Orange;
- background: Orange;
- outline: solid 1px yellow;
- }
Part2
Add a Webform named Default.aspx.
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
-
- <!DOCTYPE html>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Satyaprakash Wcf Concept</title>
- <link href="Styles.css" rel="stylesheet" />
- <script language="javascript" src="../Validation.js" type="text/javascript"></script>
- <script language="javascript" type="text/javascript">
- function Validation() {
- if (Required('<%=txtname.ClientID%>', ' Name'))
- if (Required('<%=txtGender.ClientID%>', ' Gender'))
- if (Required('<%=txtsalary.ClientID%>', ' Salary'))
- return true;
- return false;
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <h2 style="background-color: Yellow;color: Blue; text-align: center; font-style: oblique">SATYAPRAKASH's WCF CONCEPT</h2>
- <fieldset>
- <legend style="font-family:Arial Black;color:orangered">WCF INSERT USING STORED PROCEDURE</legend>
- <table align="center" border="1" cellpadding="4" cellspacing="4">
- <tr><td align="center"><asp:TextBox ID="txtname" class="textbox" runat="server" placeholder="Enter Name.."></asp:TextBox></td></tr>
- <tr><td align="center"> <asp:TextBox ID="txtGender" class="textbox" runat="server" placeholder="Enter Gender.." ></asp:TextBox></td></tr>
- <tr><td align="center"><asp:TextBox ID="txtsalary" class="textbox" runat="server" placeholder="Enter Salary.."></asp:TextBox></td></tr>
- <tr><td align="center">
- <asp:Button ID="btnsave" runat="server" Text="Save" class="button button4" OnClick="btnsave_Click" OnClientClick="javascript:return Validation();" />
- <asp:Button ID="btnreset" runat="server" Text="Reset" class="button button4" OnClick="btnreset_Click"/>
- </td></tr>
- </table>
- </fieldset>
- </div>
- <footer>
- <p style="background-color: Yellow; font-weight: bold; color:blue; text-align: center; font-style: oblique">© <script> document.write(new Date().toDateString()); </script></p>
- </footer>
- </form>
- </body>
- </html>
Description of Part2How to apply CSS classes in Server controls of ASP.NET Web page.
To apply CSS in button , proceed as shown below.
- <asp:Button ID="btnsave" runat="server" Text="Save" class="button button4" OnClick="btnsave_Click" OnClientClick="javascript:return Validation();" />
- <asp:Button ID="btnreset" runat="server" Text="Reset" class="button button4" OnClick="btnreset_Click"/>
To apply CSS in TextBoxes, proceed as shown below.
- <asp:TextBox ID="txtname" class="textbox" runat="server" placeholder="Enter Name.."></asp:TextBox>
- <asp:TextBox ID="txtGender" class="textbox" runat="server" placeholder="Enter Gender.." ></asp:TextBox>
- asp:TextBox ID="txtsalary" class="textbox" runat="server" placeholder="Enter Salary.."></asp:TextBox>
To apply CSS in tables, proceed, as shown below.
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 70%;
- }
- <table align="center" border="1" cellpadding="4" cellspacing="4">
Here CSS classes table of CSS file is added.
The output of TextBoxes of ASP.NET Web page is given below.
The output of buttons of ASP.NET Web page is given below.
The output of table of ASP.NET Web page is given below.
Summary We learned:
What is CSS in ASP.NET?
How to write CSS in ASP.NET.
How to apply CSS in ASP.NET Server Controls.
Single CSS file is sufficient for all Server Controls in ASP.NET.