I am showing a radtool tip ( which has some controls in it and Targetcontrol id = imagebutton) on clicking a image button in datagrid but I want also to show normal tooltip (aspx tooltip) on mouse hover of the image:
I did this in Itembound event of radgrid by finding the image contol and mentioned as follows
imgbtn.ToolTip="XXXX";
And when I run the code, on Mouse Hover I can see the aspx tooltip but when I click on image button above tooltip (aspx toltip) is overriding the radToolTip
Can any one suggest the solution,
Thanks,
5 Answers, 1 is accepted
I am not quite sure how you implemented it to get the described result as by design, when you tooltipify an element, the RadToolTip removes the title attribute of that element. That is why you actually cannot have both RadToolTip and regular tooltip for one element, without writing code.
You can achieve this result by defining an attribute for the ImageButton and then in the mouseover handler for the button, set the title attribute to that attribute. For example:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem) |
{ |
ImageButton target = e.Item.FindControl("ImageButton1") as ImageButton; |
if (!Object.Equals(target, null)) |
{ |
target.Attributes.Add("regularToolTip", "Regular tooltip"); |
target.Attributes.Add("onmouseover", "SetRegularToolTip(this);"); |
this.RadToolTipManager1.TargetControls.Add(target.ClientID, true); |
} |
} |
} |
javascript:
<script type="text/javascript"> |
function SetRegularToolTip(button) |
{ |
if(!button.title || button.title == '') |
button.title = button.regularToolTip; |
} |
</script> |
I have attached my test page for your reference as well.
Greetings,
Tsvetie
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
the code is working but you used tooltip manager
I am used radToolTip insted of ToolTip manager, I did lot of things in tooltip now I dont want to shift to radtooltip manager
how could I do this wth tooltip ?
Thanks,
You can use the same approach for RadToolTip. Basically, the solution I described is related to showing the regular tooltip, not RadToolTip. In case you have problems implementing the same approach with RadToolTip, just send me a simple running project, demonstrating them and I will do my best to help you get the desired result.
Greetings,
Tsvetie
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Hi,
The given approach works only when I am showing only the text in radToolTip but it fails when my radToolTip contains some controls like textbox,button, etc., in that case the regular tool tip overrides radtooltip (this happens when I remove Text property of radtooltip).
If I remove the regular tooltip, I can see radTooltip with all controls.
aspx
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ObjectDataSource1" GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound">
<MasterTableView AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="No" EmptyDataText="&nbsp;" HeaderText="No"
UniqueName="No">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Name" EmptyDataText="&nbsp;" HeaderText="Name"
UniqueName="Name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Designation" EmptyDataText="&nbsp;" HeaderText="Designation"
UniqueName="Designation">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName"
UniqueName="CategoryName">
<EditItemTemplate>
<asp:TextBox ID="CategoryNameTextBox" runat="server" Text="Hello"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/App_code/performed.gif" />
<telerik:RadToolTip ID="RadToolTip1" runat="server" Height="200px" Width="500px"
ManualClose="True" Position="Center" ShowCallout="False"
EnableAjaxSkinRendering="False" RelativeTo="BrowserWindow" Text="abcd" Skin="Gray" TargetControlID="ImageButton1" ShowEvent="onclick">
<asp:Button ID="bt1" Text="Button" runat="server" />
</telerik:RadToolTip>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<FilterMenu>
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
</telerik:RadGrid>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function SetRegularToolTip(button)
{
if(!button.title || button.title == '')
button.title = button.regularToolTip;
}
</script>
</telerik:RadCodeBlock>
aspx.cs
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
{
ImageButton target = e.Item.FindControl("ImageButton1") as ImageButton;
if (!Object.Equals(target, null))
{
target.Attributes.Add("regularToolTip", "Regular tooltip");
target.Attributes.Add("onmouseover", "SetRegularToolTip(this);");
// this.RadToolTipManager1.TargetControls.Add(target.ClientID, true);
}
}
}
any solution for this
Thanks,
We are not completely sure what is the problem and that is why we believe that the best way to proceed is that you open a new support ticket and send us a sample, fully runnable reproduction project (use Northwind or a fake programmatic datasource for the grid) along with detailed explanations of the actual and the desired behavior, screenshots and detailed reproduction steps. Once we have a better understanding on the issue we will do our best to help.
Sincerely yours,
Svetlina
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.