Sohail
Sohail

Reputation: 780

Use of css in asp.net

I have a doubt that in asp.net I am using CssClass class attribute for web server controls. And i am writing all the css code in style.css which will be in style folder of my project

    <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>

The above is the example of the textbox.

Now the question is do i need to use link tag to say that my css file is located in style folder of my project?

Upvotes: 0

Views: 11189

Answers (3)

Chait
Chait

Reputation: 1267

Yes, you have to link the style sheet file (.css) by adding the link tag.

You can also simply drag the css file into the html section of the .aspx code right under head tag, that will work too - that will create the link for you.

See the image below

Upvotes: 4

Jorge Garcia
Jorge Garcia

Reputation: 2560

No, the tag is only used to apply a class within your CSS file. Just make sure you link your CSS file with your page as follows:

<head>
<link rel="stylesheet" type="text/css" href="path_to_your.css">
</head>

Upvotes: 0

Sidharth Mudgal
Sidharth Mudgal

Reputation: 4264

Of course you need to link to your css file just like you do in regular html:

<link rel="stylesheet" type="text/css" href="style/mystyle.css">

While writing .aspx file just think as if you are writing an HTML file with the ability to pre-process the page through the ASP.NET view engine (which is where the additional asp tags come into play).

Upvotes: 1

Related Questions