简体   繁体   中英

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?

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". you should use Text='something'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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