This is a migrated thread and some comments may be shown as answers.

Append Parameter to Javascript function attached to OnClientTabSelected

5 Answers 338 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Wisanto
Top achievements
Rank 1
Wisanto asked on 24 Aug 2011, 02:49 AM
From telerik website:

Use the OnClientTabSelected property to specify a JavaScript function that will be executed after a tab is selected - either by left-clicking it with a mouse or hitting enter after tabbing to that tab.

Two parameters are passed to the handler

  • sender (the client-side RadTabStrip object)
  • eventArgs with one property
    • Tab - the instance of the selected tab

From my understanding, telerik will automatically pass 2 parameters to the handler, and we don't have to specify the parameters. However, what if I need to pass an extra parameter, something like below, how do I do it? 

function ClientTabSelectedHandler(sender, eventArgs, name) {
alert(name);
}

            <telerik:RadTabStrip ID="radTabStripTicketInfo" runat="server" 
                SelectedIndex="0" OnClientTabSelected="ClientTabSelectedHandler(sender, eventArgs, anotherControlID)">
                <Tabs>
                    <telerik:RadTab runat="server" Text="1" Selected="True">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="2">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="3">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Aug 2011, 11:35 AM
Hello Wisanto,

In order to pass parameters, you should handle it as shown below.
aspx:
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" ScrollChildren="true"
           OnClientTabSelected="function(sender, args){SelectTab(sender, args, 'Value1');}" >
 <Tabs>
  . . .....
 </Tabs>
</telerik:RadTabStrip>
               
               

Javascript:
function SelectTab(sender, args, arg1)
{
   alert("Argument passed is arg1-" + arg1);
}

Thanks,
Princy.
0
Kalaiyarasi
Top achievements
Rank 1
answered on 07 Jun 2013, 02:37 PM
Hi,

I tried the same code for RadDatePicker but it did not work. Please help.

Thanks & Regards,
Kalai
0
Eyup
Telerik team
answered on 12 Jun 2013, 11:40 AM
Hello Kalaiyarasi,

Here is a working sample:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
    <ClientEvents OnDateSelected="function(sender,args){dateSelected(sender,args,'customArgument')}" />
</telerik:RadDatePicker>
JavaScript:
function dateSelected(sender, args, argument) {
    alert(argument);
}

Hope this helps.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Michael Hunt
Top achievements
Rank 1
answered on 04 Dec 2014, 07:56 PM
All of you at Telerik are awesome.  This type of functionality is a lifesaver!

This should be documented in some help file...  or maybe it is, but I didn't see it.
0
Eyup
Telerik team
answered on 09 Dec 2014, 12:17 PM
Hello Michael,

I'm glad the provided approach has proven helpful. Perhaps, we should create a help article about this, indeed.
Thank you for your feedback.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TabStrip
Asked by
Wisanto
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kalaiyarasi
Top achievements
Rank 1
Eyup
Telerik team
Michael Hunt
Top achievements
Rank 1
Share this question
or