<script>
function
OnClientLoad(sender, args) {
var
hiddenfield = $telerik.findElement(sender.get_element().parentElement,
"RadSearchBoxDocumentTooltips"
);
if
(hiddenfield.value) {
var
tooltips = JSON.parse(hiddenfield.value)
sender.get_buttons().forEach(
function
(btn) {
if
(tooltips[btn.get_commandName()]) {
btn.get_element().title = tooltips[btn.get_commandName()];
}
})
}
}
</script>
<
asp:Panel
runat
=
"server"
>
<
telerik:RadSearchBox
RenderMode
=
"Lightweight"
runat
=
"server"
ID
=
"RadSearchBoxDocument"
EmptyMessage
=
"Search Document"
OnLoad
=
"RadSearchBoxDocument_Load"
OnClientLoad
=
"OnClientLoad"
>
<
Buttons
>
<
telerik:SearchBoxButton
runat
=
"server"
ToolTip
=
"Custom Button Tooltip"
CommandName
=
"Edit"
ImageUrl
=
"https://via.placeholder.com/16"
/>
</
Buttons
>
</
telerik:RadSearchBox
>
<
asp:HiddenField
ID
=
"RadSearchBoxDocumentTooltips"
runat
=
"server"
/>
</
asp:Panel
>
protected
void
RadSearchBoxDocument_Load(
object
sender, EventArgs e)
{
var sb = sender
as
RadSearchBox;
var hiddenField = sb.Parent.FindControl(sb.ID +
"Tooltips"
)
as
HiddenField;
var tooltips =
new
Dictionary<
string
,
string
>();
foreach
(SearchBoxButton btn
in
sb.Buttons)
{
if
(!
string
.IsNullOrWhiteSpace(btn.ToolTip))
{
tooltips.Add(btn.CommandName, btn.ToolTip);
}
}
if
(tooltips.Count > 0)
{
hiddenField.Value =
new
JavaScriptSerializer().Serialize(tooltips);
}
}