简体   繁体   English

ASP.NET Link Runat Server W3C Validator

[英]Asp.net link runat server w3c validator

when i run a link server side like this: 当我像这样运行链接服务器端时:

     <link runat="server" id="staticCss" 
href="....css?v=0" media="all" rel="stylesheet" type="text/css" />

asp.net renders it with asp.net用

<link runat="server" id="staticCss" 
href="....css?v=0" media="all" rel="stylesheet" type="text/css" ><link>

and this fails the w3 validation 这将导致w3验证失败

Stray end tag link. 流浪结束标签链接。

becasuse link tag can't end with link but must end with / 因为link标签不能以link结尾,但必须以/结尾

How can i avoid it? 我该如何避免呢?

As far as I know, it can't be avoided. 据我所知,这是无法避免的。 These are the alternatives that you have: 这些是您可以选择的选择:

  1. Use a static link tag without the server processing, if you can 如果可以,请使用静态link标记而不进行服务器处理
  2. Ignore the validation error: browsers handle this markup well and you shouldn't have any issues on your website 忽略验证错误:浏览器可以很好地处理此标记,并且您的网站上应该没有任何问题
  3. Use a .net literal to spit out the markup as text: this way you are in total control of the formatting 使用.net literal将标记作为文本吐出:这样,您就可以完全控制格式

I have been struggling with .net generated html for a long time, it can be very frustrating. 我一直在努力地使用.net生成的html,这可能会非常令人沮丧。 If anyone knows of other ways to solve this I would be very interested to learn. 如果有人知道其他解决方法,我将非常有兴趣学习。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM