1

I asked on Telerik's site, but there is apparently not enough traffic there to generate answers.

I am trying to convert an asp ImageButton to a RadImageButton because there are some useful features that would make my life a bit easier. However, the binding for the image URL won't work - at least the way I am doing it.

So this works (both are in the same ListView):

<asp:ImageButton ID="im" runat="server" ImageUrl='<%# Eval("ImgUrl") %>' />

But this:

<telerik:RadImageButton runat="server" ID="itemImageButton" '>
    <Image Url='<%# Eval("ImgUrl") %>' />
</telerik:RadImageButton>

gives me an error something like Telerik.Web.UI.ButtonBase.ButtonImage does not have a DataBinding event.

If someone could point me in the right direction to get this done with the RadImageButton control (if possible), I would appreciate it.

1 Answers1

0

I was recently facing exactly the same issue. Apparently child objects/properties in some controls are not DataBound-able.

You have to do the binding for the image URL inside the telerik:RadImageButton tag itself, so instead of using <Image Url="" /> section, place it in the Image-Url attribute:

<telerik:RadImageButton runat="server" ID="itemImageButton" Image-Url='<%# Eval("ImgUrl").ToString() %>'>
</telerik:RadImageButton>

You can ommit .ToString() part though.

One more "issue" that I've got when switching from asp:ImageButton to telerik:RadImageButton was the necessity to set the width and height explicitly. Without it, it didn't work ouf of the box. Image (icon) was malformed, even though it was like 24x24 sized. I ended up setting width="" and height="" attributes, but adding CssClass and using styles should work too.

Skipper
  • 775
  • 6
  • 17
  • 32
  • Perfect! Thanks so much! I like this so much better than binding the item databound event for the listview and handling it there. For some reason the Image-Url attribute is not showing for me in Intellisense. I agree on the size thing. I looked at the output when I found this and saw that instead of adding an image element as I expected, it adds inline styling to create a background-image on the container. The only way I can think of to resolve it dynamically is to handle it in the data bound event of the RadImageButton or the data container (RadListView in my case). – user3179754 May 24 '18 at 12:23