0

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?

1
  • You simply need to include your stylesheet in your HTML with the <style> or <link> tag. Commented Dec 6, 2012 at 23:17

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

3 Comments

you mean just by dragging and dropping the style folder into my aspx file. It will work?
No, not the folder - you have to drag the css file.
Glad to help. Don't forget to accept the answer that worked for you!
1

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).

1 Comment

If he is using themes (correctly) then the <link> element will be added automatically.
0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.