|
Article relates to
|
RadToolTip for ASP.NET AJAX,
RadComboBox for ASP.NET AJAX
|
|
Created by
|
Svetlina, Telerik
|
HOW TO:
Show a
RadToolTip when a
RadComboBox is focused
SOLUTION:
Usually, to show a
RadToolTip when an element is focused, it is enough to set the element as target control and to set
ShowEvent="OnFocus". However, the case when using
RadComboBox is slightly different because the
RadComboBox /as all
RadControls/ is complex HTML and it is formed by different standard HTML elements. The combo box has its focus event when actually the INPUT element is focused and thus you should "inform" the tooltip that this is the particular element it should use as a target.
In order to achieve this, we suggest the following two approaches:
1) Specify the target as the actual client ID of the input
The INPUT element of the
RadComboBox has its client ID formed by the ClientID of the
RadComboBox plus the suffix _Input. Note, that you should explicitly set
isClientID to
true as well because otherwise the tooltip will search for a server control with such an ID and since there is not such, an error will be thrown.
Sample code snippet which shows the approach is available below:
This approach is recommended in simple scenarios e.g with a separate
RadToolTip as shown above.
2) Handle the
RadComboBox's OnClientFocus event and show the tooltip from code
In this case you should set
ShowEvent="FromCode" for the tooltip and use its API to show it in the
OnClientFocus handler of the
RadComboBox - e.g as shown below:
This approach covers more complex scenarios as well - e.g you can use it for dynamic creation of tooltips on the client by using the
RadToolTipManager client API.
NOTE:
Note, that always when using on focus event for the tooltip you should use a little timeout /ShowDelay/ because otherwise if you use the mouse click to focus, this will trigger the tooltip to hide.
You can find a sample demo with both the approaches demonstrated in the archive below:
Download Demo