ASP.NET 4 Parser Error

纵然是瞬间 提交于 2019-12-20 05:38:52

问题


I received a asp.net 2 to upgrade to .net 4. While most of it went well I'm stuck on a line that can't find a solution for it.

I get a Parser Error Message: The server tag is not well formed.

at this line

<li><a class="tooltip viewPolicyLink" rel="<%#Eval("key")%>"
              title="<%#Eval("value")%>"
              href="<%#ResolveUrl("~/Views/Pages/ViewPolicy.aspx")%>"
              runat="server"><%#Eval("key")%></a></li>

What's wrong with it?


回答1:


you have messed with " try :

   <li><a class='tooltip viewPolicyLink' rel='<%#Eval("key")%>'
                  title='<%#Eval("value")%>'
                  href='<%#ResolveUrl("~/Views/Pages/ViewPolicy.aspx")%>'
                  runat="server"><%#Eval("key")%></a></li>



回答2:


Double quotes are nested in rel, title, href attributes.




回答3:


you need to use single quotes when setting tag values that contain the Eval() expression. The reason being is the double quotes that Eval takes.




回答4:


Try using single quotes for the attributes containing server-side commands:

<li><a class="tooltip viewPolicyLink" rel='<%#Eval("key")%>'
              title='<%#Eval("value")%>'
              href='<%#ResolveUrl("~/Views/Pages/ViewPolicy.aspx")%>'
              runat="server"><%#Eval("key")%></a></li>


来源:https://stackoverflow.com/questions/10433467/asp-net-4-parser-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!