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

[Solved] Retrieving the url of GridEditCommandColumn image

5 Answers 277 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Algo
Top achievements
Rank 1
Algo asked on 13 Mar 2013, 06:55 PM
Hello,

I have an image button on my page and I would like its image to match with the GridEditCommandColumn's one (which is based on the theme).

Is there any way to achieve this ?

Thanks !


5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Mar 2013, 05:06 AM
Hi,

Try the following code.
C#:
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
    GridDataItem item = (GridDataItem)e.Item;
    ImageButton edit = (ImageButton)item["EditColumn"].Controls[0];
    edit.ImageUrl = "~/Images/img.gif";
  }
}

Thanks,
Princy
0
Algo
Top achievements
Rank 1
answered on 14 Mar 2013, 03:07 PM
Hello Princy,

This isn't quite what i'm looking for, but maybe I wasn't being precise enough.

I have a grid, and i'm implementing a contextual menu on the grid's rows to be able to access the primary grid actions (edit, insert, delete) from there.

In the provided screenshot, the button in the grid is based on the theme and comes from the GridEditCommandColumn.
I need to be able to retrieve that image in order to use it in my contextual menu, so it matches with the GridEditCommandColumn's image, no matter what theme I am in.

Thanks!
0
Princy
Top achievements
Rank 2
answered on 15 Mar 2013, 06:34 AM
Hi,

GridEditCommandColumn's  image rendered is a SpriteImage. SpriteButtons are rendered as <input type="button" /> elements, but they have predefined CSS classes, which can be used to change their look and feel to resemble ImageButtons. Check the following help documentation which explains more about this.
CSS sprites

Thanks,
Princy
0
Algo
Top achievements
Rank 1
answered on 17 Mar 2013, 02:42 PM
Hello Princy,

I understand that sprite images are used throughout Telerik controls.

My problem here, is I have no idea where the image from this grid's column is taken from.

<telerik:GridEditCommandColumn ButtonType="ImageButton"/>

I need  to be able to use the same image outside of a grid.

Can you give me an  example/solution for this ?

Thanks!
0
Algo
Top achievements
Rank 1
answered on 20 Mar 2013, 03:55 PM
If anyone is interested in the solution to this issue:

Retrieve the button's ImageUrl (Edit button in this example) :


Telerik.Web.SkinRegistrar.GetWebResourceUrl(Page, typeof(RadGrid), String.Format("Telerik.Web.UI.Skins.{0}.Grid.Edit.gif", GetTheme()))

Tags
Grid
Asked by
Algo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Algo
Top achievements
Rank 1
Share this question
or