문제

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?

도움이 되었습니까?

해결책

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/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top