开发者

Design mode in Visual Studio doesn't ger resources specified with ResolveClientUrl

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 hre开发者_如何转开发f= "<%= 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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜