How use dynamic image URl for Image button
I have a Image button on the aspx page that is server side button.
Now I want to get image url for this from my code class. but this is not working.
<asp:ImageButton ID="total" runat="server" ImageUrl='<%=myappnamespace.Utility.GetImageURL("chckout_p.png")%>'>
Function GetImageURl
is public in Utility calls and return the full image path.
If I us开发者_运维百科ed this for the following then its working fine
<img src='<%=myappnamespace.Utility.GetImageURL("chckout_p.png")%>'>
So what is wrong with the server side controls.
You can't use <%= codeBehindData.Here %>
on server controls. You can use
<asp:ImageButton ID="total" runat="server" ImageUrl='<%# myappnamespace.Utility.GetImageURL("chckout_p.png") %>'>
Notice the <%#
Then call Page.DataBind()
or total.DataBind()
on Page_Load
精彩评论