锚标记 href 中的 eval [英] eval in anchor tag href
本文介绍了锚标记 href 中的 eval的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要实现的是在我的锚标记的 href 中使用 Eval 作为参数.锚嵌套在中继器内,为什么我不能使用后面的代码来实现这一点.
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.
我该如何处理?
推荐答案
<a href="<%# String.Format("http://MyWebsite/ActiveUsers?ID={0}", Eval("ID")) %>">
这篇关于锚标记 href 中的 eval的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文