i have an image tag like
<asp:Image ID="ImgProduct" runat="server" ImageUrl='<%# FormatImageUrl("10")%>' />
and in code behind i have a method like
protected string FormatImageUrl(string s)
{
return "image"+s;
}
when i rum the code i am expecting that an HTML image tag with src="image10" will render.
but nothing happens why? any clues?
i am in asp.net . not mvc
Right-click the . aspx page, and then click View Code. The code-behind file opens in the editor.
the <%# .. %>
is applied only during data binding. One solution is to manually call DataBind()
Try
protected void Page_Load(object sender, EventArgs e)
{
ImgProduct.DataBind();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With