Thursday, October 18, 2007

Using StyleSheets in asp.net.

If you are a novice, how will you design your pages in asp.net.You will choose the colors, font and all the other designing aspects from the properties box of that particular web control.But do you think that this is a nice idea.No, it is not.
For making it easy, generous and to bring a uniformity to our application, we use style sheets.
Using style sheets is a comman way of designing our webforms.

So, how to use them in asp.net. This is the way:-
Steps:
1)Add the following tag in the HTML part of your page -
link rel="stylesheet" type="text/css" href="styles/style.css"

Note: I have used it within the 'HEAD' tag.
2)Create a new folder--- styles in under your project.
3)Within that folder, create a .css file - Style.css(Add new item)
4)Add some classes in that .css file like:-

.defaultTxt{font-family : Verdana, Arial, sans-serif ;
font-size:34px;
background-color:Black;}
5)Save it.
6)Now to use these style format in a button control:-
For example-
asp:button id="Button1" cssclass="defaultTxt" runat="server" text="Button"

That is the simplest and easiest way to use style sheets in your code.

No comments: