ASP.NET 4 Parser Error

2020-04-21 01:57发布

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?

4条回答
SAY GOODBYE
2楼-- · 2020-04-21 02:35

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>
查看更多
做自己的国王
3楼-- · 2020-04-21 02:42

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>
查看更多
SAY GOODBYE
4楼-- · 2020-04-21 02:43

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.

查看更多
欢心
5楼-- · 2020-04-21 02:59

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

查看更多
登录 后发表回答