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

Pass custom parameters to Client Events

3 Answers 578 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
reza
Top achievements
Rank 1
reza asked on 29 Jun 2012, 08:50 AM
Hi
How can I pass a custom parameter to a Client Event ?
for example how can I pass a parameter to 'OnClientClicked' of 'RadButton' control ?
I want to define a function for 'OnClientClicked' in C# and pass a custom parameter to this function
  -> myBtn.OnClientClicked = "eventHandler(...);"
and access this parameter in javascript function , is it possible ?

Thank you very much for your feedback

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Jul 2012, 09:47 AM
Hello,

function OnClientClicked(sender, eventArgs) {
                 
                alert(document.getElementById(sender.get_id()).getAttribute("Test"));
            }
<telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" OnClientClicked="OnClientClicked">
       </telerik:RadButton>
RadButton1.Attributes.Add("Test","YourValue");


Thanks,
Jayesh Goyani
0
Slav
Telerik team
answered on 03 Jul 2012, 12:01 PM
Hi guys,

I would suggest checking also the Code Library article Passing user-defined parameters to client-side event handlers as it describes three useful methods for passing a custom parameter to a RadButton client-side event handler.

Greetings,
Slav
the Telerik team
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 their blog feed now.
0
Marcel
Top achievements
Rank 1
answered on 20 Dec 2017, 10:39 PM
Jayesh your solution worked well for me. Thanks.
Tags
General Discussions
Asked by
reza
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Slav
Telerik team
Marcel
Top achievements
Rank 1
Share this question
or