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

Changing GridTemplateColumn image button url client-side

2 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jill Allison
Top achievements
Rank 1
Jill Allison asked on 26 Apr 2010, 10:28 PM
Hello,

I have an expandable RadGrid.  Inside the DetailTable of the grid, I have a GridTemplateColumn with an image button.

Can you tell me how to, on the OnCommand event of the image button, change the image url?  I want to do this via client-side script only.  No server-side postback.  Or if I need to do it another way (instead of using the OnCommand event), can you tell me that as well?

Thanks,
RezRaider

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 Apr 2010, 07:59 AM
Hello Jill,

You can change the Image url by attaching OnClientClick event for the ImageButton. Check out the following code and i hope it will help you.

ASPX:
<telerik:GridTemplateColumn> 
 <ItemTemplate> 
     <asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="changeUrl(this); return false;" ImageUrl="~/Images/untitled.bmp" /> 
 </ItemTemplate> 
</telerik:GridTemplateColumn> 

JAVA SCRIPT:
<script type="text/javascript"
    function changeUrl(btn) { 
         btn.src = "../Images/NewImage.bmp"
    } 

Regards,
Shinu.




0
Jill Allison
Top achievements
Rank 1
answered on 27 Apr 2010, 02:37 PM
Thank you, Shinu!  I was making it more complicating than it actually was.  :)

Rez
Tags
Grid
Asked by
Jill Allison
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jill Allison
Top achievements
Rank 1
Share this question
or