[英]ASP.NET Server Tags
When I use: 我用的时候:
<asp:Label id="lbCatId" runat="server" Text='<%# Eval("VideoId") %>' Visible="true" />
I get: 我明白了:
<span id="ctl00_mainContent_ucCoverFlow_rptVideos_ctl00_lbCatId">5</span>
However when I use: 但是当我使用时:
<asp:Image runat="server" href='Play.aspx?VideoId=<%# Eval("VideoId") %>' ID="iThumbnailFileName" CssClass="content" />
I get: 我明白了:
<img id="ctl00_mainContent_ucCoverFlow_rptVideos_ctl01_iThumbnailFileName" class="content" href="Play.aspx?VideoId=<%# Eval("VideoId") %>"
I would like to know why C# isn't generating the 'VideoId' like it is in the first example. 我想知道为什么C#没有像第一个例子那样生成'VideoId'。
Try using the ImageUrl
property instead. 请尝试使用
ImageUrl
属性。 The href
attribute probably doesn't know how to interpret databinding syntax. href
属性可能不知道如何解释数据绑定语法。
<asp:Image ID="Image1" runat="server" ImageUrl='Play.aspx?VideoId=<%# Eval("VideoId") %>' ...>
You are printing the string of the command you want to execute instead of executing it. 您正在打印要执行的命令的字符串而不是执行它。
Use : 采用 :
'<%# "Play.aspx?VideoId=" + Eval("VideoId") %>'
Instead of : 代替 :
'Play.aspx?VideoId=<%# Eval("VideoId") %>'
你有没有尝试过:
<asp:Image runat="server" href='<%# "Play.aspx?VideoId=" + Eval("VideoId") %>' ID="iThumbnailFileName" CssClass="content" />
Try to change: 尝试改变:
href='Play.aspx?VideoId=<%# Eval("VideoId") %>'
to 至
href='<%# "Play.aspx?VideoId=" + Eval("VideoId") %>'
'<%#Eval(“VideoId”,“Play.aspx?VideoId = {0}”)%>'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.