7 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Feb 2009, 04:58 AM
Hello Markus,
You can access the ImageButton in the ButtonColumn and add corresponding attributes to it to add hovereffect to it, as shown below:
aspx:
cs:
Thanks
Princy.
You can access the ImageButton in the ButtonColumn and add corresponding attributes to it to add hovereffect to it, as shown below:
aspx:
| <telerik:GridButtonColumn Text="Button" ButtonType="ImageButton" ImageUrl="~/image.gif" HeaderText="ButtonColumn" UniqueName="ButtonColumn"> |
| </telerik:GridButtonColumn> |
cs:
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| GridDataItem item = (GridDataItem)e.Item; |
| ImageButton btn = (ImageButton)item["ButtonColumn"].Controls[0]; |
| btn.Attributes.Add("onMouseOver", "this.style.backgroundColor = 'red';"); |
| btn.Attributes.Add("onMouseOut", "this.style.backgroundColor = '';"); |
| } |
| } |
Thanks
Princy.
0
Markus
Top achievements
Rank 1
answered on 05 Feb 2009, 09:34 AM
Hello Princy,
I get it work, thanks!
Regards Markus
I get it work, thanks!
Regards Markus
0
Rishi
Top achievements
Rank 1
answered on 26 Nov 2013, 07:48 PM
Hi
Is this the only way we can edit the style/ attributes on the image button ? Can we do it from the client side ?
Is this the only way we can edit the style/ attributes on the image button ? Can we do it from the client side ?
0
Princy
Top achievements
Rank 2
answered on 27 Nov 2013, 07:16 AM
Hi Rishi,
Please try the following code snippet to set Hover-style from client side.
ASPX:
JS:
Thanks,
Princy
Please try the following code snippet to set Hover-style from client side.
ASPX:
<ClientSettings> <ClientEvents OnRowMouseOver="RowMouseOver" OnRowMouseOut="RowMouseOut" /></ClientSettings>JS:
<script type="text/javascript"> function RowMouseOver(sender, args) { var i = args._itemIndexHierarchical; var MasterTable = sender.get_masterTableView(); var image = MasterTable.get_dataItems()[i].findElement("UniqueName"); image.style.backgroundColor = 'red'; } function RowMouseOut(sender, args) { var i = args._itemIndexHierarchical; var MasterTable = sender.get_masterTableView(); var image = MasterTable.get_dataItems()[i].findElement("UniqueName"); image.style.backgroundColor = ''; }</script>Thanks,
Princy
0
Richard
Top achievements
Rank 1
answered on 27 Feb 2014, 04:08 PM
How can I do the same thing for a button type "PushButton"?
0
Richard
Top achievements
Rank 1
answered on 27 Feb 2014, 04:13 PM
Your example showed mouser over option for Image button - I there a similar option for PushButton
protected void radGrid_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; ImageButton btn = (ImageButton)item["ButtonColumn"].Controls[0]; btn.Attributes.Add("onMouseOver", "this.style.backgroundColor = 'red';"); btn.Attributes.Add("onMouseOut", "this.style.backgroundColor = '';"); } }0
Princy
Top achievements
Rank 2
answered on 28 Feb 2014, 04:20 AM
Hi Richard,
You can obtain the same for a PushButton type. Just access the control as Button in code-behind instead of the ImageButton as follows:
C#:
Thanks,
Princy
You can obtain the same for a PushButton type. Just access the control as Button in code-behind instead of the ImageButton as follows:
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; Button btn = (Button)item["ButtonColumn"].Controls[0]; btn.Attributes.Add("onMouseOver", "this.style.backgroundColor = 'red';"); btn.Attributes.Add("onMouseOut", "this.style.backgroundColor = '';"); }}Thanks,
Princy