Click here to Skip to main content
15,353,726 members
Please Sign up or sign in to vote.
1.11/5 (4 votes)
See more:
hai sir,this is voijaya durga.I am doing realtime project. how to add css file to asp.net project please send the quick reply sir
Posted

Add CSS in project:
In SolutionExplorer --> Right click o project --> Add existing item and select Stylesheet(CSS).

Use CSS in ASPX page:
You need add refererence of CSS file in ASPX page
<link href="Stylesheet.css" rel="stylesheet" type="text/css" />
   
to add new css file..

right click on your project - Add new item - select stylesheet - click Ok

to add existing .css file..

right click on your project - Add existing item - browse for file - click Ok
   
Hi Prince,
to add new css file..

right click on your project - Add new item - select stylesheet - click Ok

to add existing .css file..

write like this
.body
{
    background: #b6b7bc;
    font-size: .80em;
    font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif;
    margin: 0px;
    padding: 0px;
    color: #696969;
}

and in aspx page you can refere
<link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" />

Tank U.
   
v2
HI ,
the solution to your question is below:

First Open Your "MasterPage"-> add the selected Css page in master page->
Drag and drop css below header file->then go to downloaded css template and open that template -> right click on the template and click the option "view page source" -> copy the template body code-> open the master page -> paste the template body code within the body of master page.
   
First you have to add your css to your project hierarchy...
good way to do that is to create a separate folder for example named as style in project hierarchy and add your css file in that.. either by right click and add existing item. or by opening project in window file explorer and pasting your file there in desired folder.


anyways after when you have css file in your project hierarchy.. you can use it on the specific page where you want by adding reference like below.


<link type="text/css" rel="stylesheet" href="Folder hierarchy/cssfilename" />



NOTE.... gud way to reach your desired css file in href tag is to just leave the cursor after putting first quote there.. you will be seeing a "Pick URL" option.. and you can use that to reach your css widout any mistake.


Hope it will help.

:)
   
Comments
CHill60 13-Jun-13 8:49am
   
Hi - it's good that you want to help but this post is over a year old and already has 7 solutions posted. Just to let you know, posting solutions to old, answered questions often attracts downvotes.
VICK 13-Jun-13 8:54am
   
and btw thanks alot for downvoting it... !!!
CHill60 13-Jun-13 9:00am
   
That wasn't me. It was already downvoted when I got here which is why I looked
VICK 14-Jun-13 1:21am
   
okay fine.. but whoever down voted it,, should share the reason of that as well....
VICK 13-Jun-13 8:52am
   
Ya.. i know that.. but have you seen the same question's Solution NO.04 being edited just 2 minutes ago by "Savalia Manoj"??? and it is also showing in "UnAnswered Questions"... So i thot that might be some one needed it again.. and i just posted a answer.. Hope now ur objection will be not as before... :)
ADding CSS Direct in page use <Style> tag .... Like..........


<head runat="server">
<style type="text/css">
.class1
{
margin:0px auto;
width:990px;
}
</style>
<title></title>
</head>
<asp:Button ID="btnABC" CssClass="class1" runat="server" Text="TEST"/>
   
v2
SQL
for a new css file..

right click on your project - Add new item - select stylesheet - click Ok

if u have already an css file and want to add that with your projec t then go this way

right click on your project - Add existing item - browse for file - click Ok


for add it to your project

   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900