ASP.NET 4 Parser Error

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(" rel="nofollow noreferrer noopener"~/Views/Pages/ViewPolicy.aspx")%>"
              runat="server"><%#Eval("key")%></a></li>

What’s wrong with it?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 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>

Solution 2

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

Solution 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.

Solution 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>

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply