Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include .css files in asp.net

Since virturl directory name is not fixed, I wrote code below to include .css file in .aspx page now.

<link rel="Stylesheet" href="<%= ResolveUrl("~/Css/xxx.css") %>" type="text/css" />

The question is, when I use "ResolveUrl" in tag, IDE is always barking about that all CSS classes is undefined.

Is there any better way to define .css file including?

like image 969
but Avatar asked Jul 22 '10 01:07

but


Video Answer


1 Answers

You can do this with html server controls (notice the runat="server") like so:

<link rel="stylesheet" runat="server" media="screen" href="~/css/styles.css" />

This will still resolve the virtual directory for you. It should also support the css intellisense and warnings on the aspx page.

like image 69
EndangeredMassa Avatar answered Sep 18 '22 22:09

EndangeredMassa