How to set a location for alternative text in <asp:image button>
<asp:ImageButton ID="ImageButton2" runat="server" Width="100px"
AlternateText='<%# Eval("Img_Id")%>' Height="100px"/>
In the AlternateText='<%# Eval("Img_Id")%>'
I have to write somethin开发者_如何学JAVAg like this:
'~/images/<%# Eval("Img_Id")%>'
You can just do the following:
<asp:ImageButton ID="ImageButton2" runat="server" Width="100px" Height="100px"
AlternateText='<%# this.ResolveUrl("~/images/" + Eval("Img_Id")) %>'/>
Here is a link to some information that will explain url and paths resolving.
EDIT: as per my comment, I think you are not using the correct property set the following property to display the image. Your orignal question just looked like you were trying to set the AlternateText
property which will not do anything for the image:
ImageUrl='<%# this.ResolveUrl("~/images/" + Eval("Img_Id")) %>'
<asp:ImageButton ID="ImageButton2" runat="server" Width="100px"
AlternateText='<%# "~/images/" + Eval("Img_Id").toString()%>' Height="100px"/>
^^
精彩评论