Jul 22, 2008, 10:49 PM
[CLOSED] Tooltips?
Is there any way for ext:Buttons to have tooltips?
Thanks!
<ext:ScriptManager ID="ScriptManager1" runat="server">
<Listeners>
<DocumentReady Handler="
this.tt = new Ext.ToolTip({
target: '{Button1}',
title: 'Please click this button'
});" />
</Listeners>
</ext:ScriptManager>
<ext:Button ID="Button1" runat="server" Text="Submit" />
In the sample above, I wrap the "Button1" ID in curly braces {} which creates a ID token/template. The token is then converted to the client-side ID (.ClientID) of the control when rendered. The client-side ID may be different than the server-side ID. <ext:Button ID="Button1" runat="server" Text="Submit">
<ToolTips>
<ext:ToolTip ID="ToolTip1" runat="server" Title="ToolTip added to the Button..." />
</ToolTips>
</ext:Button>
The following sample demonstrates adding a more complex ToolTip which also listens for the ToolTip Show and Hide events. By default the ToolTip does not follow the mouse movements, but setting the .TrackMouse property to "true" enables mouse movement tracking. The <Show> and <Hide> Listeners in this example just log a message to the FireBug (FireFox plugin) console. <ext:Button ID="Button2" runat="server" Text="Submit">
<ToolTips>
<ext:ToolTip
ID="ToolTip2"
runat="server"
Title="More complex ToolTip..."
TrackMouse="true"
HideDelay="1000">
<Listeners>
<Show Handler="console.log('ToolTip2 Shown');" />
<Hide Handler="console.log('ToolTip2 Hidden');" />
</Listeners>
</ext:ToolTip>
</ToolTips>
</ext:Button>
ToolTips can also be added to any other Control or html element on the Page. The following demonstrates adding a ToolTip to a classic <asp:Button>.<asp:Button ID="Button3" runat="server" Text="Button" />
<ext:ToolTip ID="ToolTip3" runat="server" Title="Generic ToolTip to an asp:Button Control" Target="Button3" />
The following demonstrates adding a two(2) ToolTips to a regular . Notice that the does not contain a runat="server" attribute. ToolTips can be added to any html element. The ToolTip5 demonstrates using the Ext.get function to find an element on the Page, instead of hard coding the id. Wrapping the Ext.get script with curly braces {} is required. <div id="div1" style="width:100px;height:100px;border:2px solid
blue;background-color:yellow;">My custom div element
<ext:ToolTip
ID="ToolTip4"
runat="server"
Title="ToolTip added to a generic div!"
Target="div1"
/>
<ext:ToolTip
ID="ToolTip5"
runat="server"
Title="ToolTip on div using using script to get Element"
Target="{Ext.get('div1')}"
TrackMouse="true"
/>
I have to leave for a meeting, but when I get back later today I'll upload these samples to sandbox.ext.net. <div id="div1" class="yellowBox">My custom div element
<ext:ToolTip
ID="ToolTip6"
runat="server"
Title="ToolTip using DomQuery"
Target="{Ext.query('.yellowBox')[0]}"
TrackMouse="true"
/>
Needless to say, using Ext.query can provide extremely powerful selector functionality to the ToolTip control.