Search code examples
asp.netsharepointeval

eval in anchor tag href


What I am trying to achieve is to use an Eval as parameter in my anchor tag's href. The anchor is nested inside a repeater, why I cannot use the code behind to achieve this.

I have tried a few things without any luck.

<a href="http://MyWebsite/ActiveUsers?ID=InsertEvalHere"><%# Eval("Name")%></a>

The following code below is what I have tried to do:

<a href="<% "http://MyWebsite/ActiveUsers?ID=" + DataBinder.Eval(Container.DataItem("ID"))%>"><%# Eval("Name")%></a>

<a href="<% "http://MyWebsite/ActiveUsers?ID=" + Eval("ID")%>"><%# Eval("Name")%></a>

<a href="http://MyWebsite/ActiveUsers?ID=<% DataBinder.Eval(Container.DataItem("ID"))%>"><%# Eval("Name")%></a>

<a href="http://MyWebsite/ActiveUsers?ID=<%# Eval("ID")%>"><%# Eval("Name")%></a>

None of the above seemed to be right, as I keep getting this error - The tag is not well formed.

How should I handle this?


Solution

  • <a href="<%# String.Format("http://MyWebsite/ActiveUsers?ID={0}", Eval("ID")) %>">