开发者

How use dynamic image URl for Image button

开发者 https://www.devze.com 2023-03-24 00:37 出处:网络
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.

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

0

精彩评论

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