RadTabStrip provides a number of client-side events that would allow you to accomplish
even the most complicated tasks.
You can attach to the RadTabStrip's events by using either the server-side properties or the client-side API.
- Attaching event handlers via a server-side property
Each client-side event has a corresponding property, whose name is formed like OnClient[EventName].
You can set the property to the name of the function to be called when the event
occurs.
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnClientTabSelected="onTabSelected">
</telerik:RadTabStrip>
<script type="text/javascript" >
function onTabSelected(sender, args)
{
alert("Selected: " + args.get_tab().get_text());
}
</script>
- Using the client-side API to attach event handlers
Using the client-side API of RadTabStrip allows you to attach multiple event handlers
to one event using the standard MS AJAX conventions.
<script type="text/javascript">
function onTabSelectedHandler1()
{
alert("First handler called");
}
function onTabSelectedHandler2()
{
alert("Second handler called");
}
function pageLoad()
{
var tabStrip = $find("<%=RadTabStrip1.ClientID%>");
tabStrip.add_tabSelected(onTabSelectedHandler1);
tabStrip.add_tabSelected(onTabSelectedHandler2);
}
</script>
Another advantage of the client-side API is the possiblity of dynamically detaching
certain handlers. You can use the remove_tabSelected method of the
tabstrip object.
<script type="text/javascript">
$find(<%=RadTabStrip1.ClientID%>).remove_tabSelected(onTabSelectedHandler1);
</script>
- Cancelling an event
The events, whose names end in ing, can be cancelled. You can cancel
the event by using the set_cancel method of the event arguments
passed to the handler.
<script type="text/javascript">
function onClientTabSelecting(sender, eventArgs)
{
eventArgs.set_cancel(true);
}
</script>