views:

99

answers:

1

I use ResolveClientUrl to include css files in my page. When launched through web-server everything is OK, but in design mode css styles are not applied to the page. I use VS 2010 beta 2.

<link href= "<%= ResolveClientUrl("~/Styles/Site.css") %>" rel="stylesheet" type="text/css" />

Same thing happens when I use any expression to specify an url for css. How can I fix it? Or is it a bug of beta?

+1  A: 

It's an inherent limitation of both. I contacted microsoft 3 years ago about the exact same issue.

The solution is to put the path directly inside the href attribute. It should work properly then.

It may, however, malfunction at runtime, depending upon your use of URL rewriting or routing. The real bug here isn't in the design mode, but in the ASP.NET framework, because it doesn't parse and resolve <link> tags properly when they are used inside content pages (dig around with Reflector to find out for yourself)...

You can read more about the issue and how to fix it in a (hopefully) future-proof manner here: http://nathanaeljones.com/146/referencing-stylesheets-scripts-from-content-pages/

Computer Linguist
Thank tou for your reply and explanation. BTW, on your page links for downloading files are corrupt.I decided to add a literal in header with correct at design time path and append it to path specified in apllicationSettings at page load-time to form full URL.So it makes possible to change path to CSS without recompilation and even serve it by another server. Same thing with scripts and images.In my case only a part of a website is served by ASP.Net. Older path is written in PHP and server by Apache. And Apache reverse prxies request to newer ASP.Net site served by IIS on another server.
flashnik
Thanks for the heads up.... I guess I missed some links during my recent migration to wordpress. The download links should work now, but the live test case isn't working yet.
Computer Linguist