简体   繁体   English

文本标签属性ASP.Net中的eval和anchor tag href

[英]eval and anchor tag href in a text label property ASP.Net

I have been trying to get these running looking at lots of different samples but with no luck. 我一直在尝试让这些程序运行在许多不同的样本上,但是没有运气。

To me it seems it's ok but what am I missing here? 对我来说似乎还可以,但是我在这里想念的是什么?

<asp:Label ID="Label1" runat="server" Text="<%# String.Format("<a href=http://localhost/reportserver/Pages/ReportViewer.aspx?/temp&rs:Command=Render&id={0}>link</a>", Eval("ID")) %>" Width="100px" visible="true"></asp:Label>

Thanks 谢谢

"With no luck" is not a descriptive error. “没有运气”不是描述性错误。

<%# is for databinding expression only. <%#仅用于数据绑定表达式。 So have you called Page.DataBind() or at least Label1.DataBind() in codebehind? 那么,您是否在代码隐藏中调用了Page.DataBind()或至少Label1.DataBind()

You could also try 您也可以尝试

Text='<%= String.Format("<a href=http://localhost/reportserver/Pages/ReportViewer.aspx?/temp&rs:Command=Render&id={0}>link</a>", Eval("ID")) %>'

Apart from that, why not doing such things in codebehind only, so you don't have issues like this? 除此之外,为什么不只在代码隐藏中做这些事情,这样您就不会遇到这样的问题?

<asp:Label ID="Label1" runat="server" Text='<%# String.Format("<a href=http://localhost/reportserver/Pages/ReportViewer.aspx?/temp&rs:Command=Render&id={0}>link</a>", Eval("ID")) %>' Width="100px" visible="true"></asp:Label>

you shouldn't use Text="something". 您不应该使用Text =“ something”。 you should use Text='something' 您应该使用Text ='something'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM