开发者

Why does the ASP.NET text shorthand in HTML header not render?

So.. this is the upper part of my ASPX file in an MVC project:

<head runat="server">
   <link href="<%= ViewData[SomeNamespace.StyleSheetKey];" %> rel="stylesheet" type="text/css" />
</head>
<div foo="<%= (string) ViewData[SomeNamespace.StyleSheetKey] %>">bar</div>

Now the div tag renders the stylesheet name properly, but the one in the link-tag is rende开发者_开发百科red as it is written, without being interpreted. In addition a path prefix is added.

So the ASP.NET engine seems to want to hassle with the text in the href-argument in the link tag, "helping" me to prefix my .css file with the correct relative path.

  1. Why? Don't you think I'm able to write the correct path myself?
  2. How will I now be able to set the name of the style sheet programatically?


Well to start

<%= ViewData[SomeNamespace.StyleSheetKey];" %>

needs to be

<%= ViewData[SomeNamespace.StyleSheetKey]; %>"

You got the quotes in the wrong place.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜