3

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 used 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.

1
  • Try setting it from code-behind cs file: myappnamespace.Utility.GetImageURL("chckout_p.png") and watch out if you get any errors. Commented Aug 1, 2011 at 7:36

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.