开发者

ASP.NET Server Tags

When I use:

<asp:Label id="lbCatId" runat="server" Text='<%# Eval("Vid开发者_StackOverflow社区eoId") %>' 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=&lt;%# Eval(&quot;VideoId&quot;) %>"

I would like to know why C# isn't generating the 'VideoId' like it is in the first example.


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") %>'


Try using the ImageUrl property instead. The href attribute probably doesn't know how to interpret databinding syntax.

<asp:Image ID="Image1" runat="server" ImageUrl='Play.aspx?VideoId=<%# Eval("VideoId") %>' ...>


Have you tried:

<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}") %>'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜