Cascade Style Sheet (CSS) in ASP.NET
Cascade Style Sheets are used to give unique look and feel to web applications or throughout the websites or to all the web sites running on a server. Cascade Style Sheets give a ‘style of how the page looks like and what color combinations should the controls of the page should bear. Cascade Style Sheet (CSS) is only associated with the presentation of a web page. It has nothing to do with the functionality or logic of the web site. This quick tutorial outlines the ways to use Cascade Style Sheet in ASP.NET.
Why to use Cascade Style Sheet (CSS)?
1. Consistent look and feel of controls in a page.
2. Unique interfaces throughout the website.
3. Easy to apply same style to all controls.
4. Applying and editing style and theme changes to overall website made easier.
Creating Cascade Style Sheet in Visual Studio 2005
1. Right click the website in the solution explorer.
2. Click Add New Item.
3. Choose Style Sheet from the Visual Studio Installed Templates.
4. Give the cascade style sheet a name. Click OK.
Now we have a cascade style sheet. We define the body section of the cascade style sheet. Insert following code into the body:
Create a class below the body section as below:
Here the class name is myControl. You can use your own class name. You can make as many classes as you wish with necessary properties set. For the properties available for Cascade Style Sheet you can read references at the bottom of this quick tutorial.
Applying Cascade Style Sheet
Now we have a simple Cascade Style Sheet. We can apply it to any control or the whole page itself.
Applying Cascade Style Sheet to a control
1. Right click the control in which to use the cascade style sheet.
2. Go to properties.
3. Right to the CssClass, give the name of the class (myControl in our case).
4. Save changes.
The change can be seen in the layout of the control you used the style sheet in.
Most of the times programmers fill the DataTable from database. This action fills the schema of the database table into the DataTable . We ...
The asp.net Eval() and Bind() expressions are heavily used in asp.net GridView and DetailsView data bound controls. The difference between ...
I have oracle database installed in my computer. My Operating system is XP. I wrote an application in asp.net. It connected to oracle databa...
Last time I got the following error: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related ...
We do have a folder (and a number of sub folders) with a number of various files in those folders (and sub folders). Now we do need to list ...
Much often we open child windows from parent web page . In the child page we perform some activities, and later close the window. At the ver...
The default behaviour of asp.net gridview is that it hides both Gridview header and footer when no data is present. You can note the absence...