This is a migrated thread and some comments may be shown as answers.

Alternate hover image for GridButtonColumn when ButtonType is Image

2 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 01 Mar 2011, 05:42 PM
Is there a property that I can set to show an alternative image when I hover over a GridButtonColumn control item when the ButtonType is set to ImageButton?

I guess I could add an ItemCreated handler in the code behind to handle this but I would have thought this functionality would be quite widely desired and hence built in to the control by now?

How about it Telerik? If it's not a feature yet, can this be considered a feature request?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2011, 06:19 AM
Hello Karl,

Try the following code snippet to achieve the same.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridDataItem)
     {
         GridDataItem item = (GridDataItem)e.Item;
         ImageButton img = (ImageButton)item["ButtonImageChange"].Controls[0];
         img.Attributes.Add("onmouseover", "this.src='../Images/NewImage.jpg'");
         img.Attributes.Add("onmouseout", "this.src='../Images/Image.jpg'");
     }
 }

aspx:
<telerik:GridButtonColumn UniqueName="ButtonImageChange" HeaderText="ButtonImageChange"
                       ButtonType="ImageButton" ImageUrl="..\Images\Image.jpg">
</telerik:GridButtonColumn>

Thanks,
Shinu.
0
Karl
Top achievements
Rank 1
answered on 02 Mar 2011, 03:54 PM
Yep, Thats what I thought I'd have to do. My point was wouldnt it be more intuitive to have the following...

<telerik:GridButtonColumn 
    UniqueName="ButtonImageChange" 
    HeaderText="ButtonImageChange"
    ButtonType="ImageButton" 
    ImageUrl="..\Images\Image.jpg"
    HoverImageUrl="..\Images\ImageHovered.jpg">
</telerik:GridButtonColumn>
Tags
Grid
Asked by
Karl
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Karl
Top achievements
Rank 1
Share this question
or