CSS - 与代码结合时出错
在视图中给出以下代码片段:
<style type="text/css">
input[type=text] {
width: <%: Model.CmsConfiguration.cms_form_width %>px;
}
</style>
现在,到目前为止都有效。但 Visual Studio 现在在此视图中显示一个严重错误,例如 Validation (CSS 2.1): '<%:' is not a valid value for the 'width' property.
。有办法摆脱这个吗?
感谢您的任何提示 SL3DG3
Given following snippet in a view:
<style type="text/css">
input[type=text] {
width: <%: Model.CmsConfiguration.cms_form_width %>px;
}
</style>
Now, that works so far. But visual studio shows now a nasty error within this view like Validation (CSS 2.1): '<%:' is not a valid value for the 'width' property.
. Is there a way to get rid of this?
Thx for any tipps
sl3dg3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将 <%: 替换为 <% =
效果很好
Try replacing <%: at <% =
works well
您可能最好使用一个
通用处理程序
来生成您想要的动态CSS。看看这里:
http://www.brainbell.com/tutorials/ ASP/Generic_Handlers_%28ASHX_Files%29.html
处理程序生成一个
select
这不是一个好主意,但让它生成 CSS 似乎是一件完全有效的事情。该示例只是为了演示通用处理程序的使用。这可能会满足您的需求:
You are probably better off using a
Generic Handler
that produces the dynamic CSS as you want.Have a look here:
http://www.brainbell.com/tutorials/ASP/Generic_Handlers_%28ASHX_Files%29.html
The handler produces a
select
which is not such a good idea, but to have it produce CSS seems like a perfectly valid thing to do. The example is merely to demonstrate the use of theGeneric Handler
.Here is something that might do what you are after: