Hi,
I would like to register a second event handler for the RadToolBar's client side event "OnClientButtonClicked". Is that somehow possible?
The first event was registered by adding it to the toolbar's "OnClientButtonClicked" property.
Best regards
Ferdinand
I would like to register a second event handler for the RadToolBar's client side event "OnClientButtonClicked". Is that somehow possible?
The first event was registered by adding it to the toolbar's "OnClientButtonClicked" property.
Best regards
Ferdinand
5 Answers, 1 is accepted
0
Hello Ferdinand,
I'm afraid that you can have only one handler for an event.
Regards,
Yana
the Telerik team
I'm afraid that you can have only one handler for an event.
Regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Shinu
Top achievements
Rank 2
answered on 27 Jul 2010, 08:42 AM
Hello,
I am getting confused about why you are trying to add two event handlers for same event and also I am not sure about whether it is possible. Could you elaborate the scenario that you are trying?
If you want to change the event handler to new handler from code behind, then you could try setting new name for OnClientButtonClicked.
aspx:
Code behind:
Client code:
-Shinu.
I am getting confused about why you are trying to add two event handlers for same event and also I am not sure about whether it is possible. Could you elaborate the scenario that you are trying?
If you want to change the event handler to new handler from code behind, then you could try setting new name for OnClientButtonClicked.
aspx:
<
telerik:RadToolBar
OnClientButtonClicked
=
"clicked1"
ID
=
"RadToolBar1"
runat
=
"server"
>
<
Items
>
. . .
</
Items
>
</
telerik:RadToolBar
>
Code behind:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
RadToolBar1.OnClientButtonClicked =
"clicked2"
; // Change the handler
}
Client code:
<script type=
"text/javascript"
>
function
clicked1(sender, args) {
// default handler
alert(
"clicked1"
);
}
function
clicked2(sender, args) {
// New handler
alert(
"clicked2"
);
}
</script>
-Shinu.
0

Ferdinand
Top achievements
Rank 1
answered on 27 Jul 2010, 01:54 PM
Hi and thanks for the answers.
@Shinu: To my intentions: In my project every page has a toolbar. I wrote a UserControl that adds a button to the toolbar which calls a RadTooltip clientside. Some of my toolbars already have handlers for OnButtonClicked so that I have to attach another one for the event.
@Yana: Sorry I have to disagree with you but actually I found a way to add a second handler to the toolbar's OnClientClicked. After some debugging I found the following way:
By using the function "add_buttonClicked" it is possible to add another handler to the event.
Best regards
Ferdinand
@Shinu: To my intentions: In my project every page has a toolbar. I wrote a UserControl that adds a button to the toolbar which calls a RadTooltip clientside. Some of my toolbars already have handlers for OnButtonClicked so that I have to attach another one for the event.
@Yana: Sorry I have to disagree with you but actually I found a way to add a second handler to the toolbar's OnClientClicked. After some debugging I found the following way:
function
AddHandlerToToolbar(toolbarClientId) {
var
toolbar = $find(toolbarClientId);
if
(toolbar !=
null
) {
toolbar.add_buttonClicked(OnCsvButtonClicked);
}
}
Best regards
Ferdinand
0

Sébastien
Top achievements
Rank 1
answered on 28 Jul 2010, 07:17 PM
I'm intrigued because it is actually working, but why is it working and why do would you one two event handler for the same event???. Really confusing...
0
Hello,
Ferdinand: you are right about that - you can register more handlers for the same client event using client-side code (not in the aspx page). I'm sorry for my mistake.
Sébastien: actually this is how javascript works - you can also attach two click events to a button.
Best wishes,
Yana
the Telerik team
Ferdinand: you are right about that - you can register more handlers for the same client event using client-side code (not in the aspx page). I'm sorry for my mistake.
Sébastien: actually this is how javascript works - you can also attach two click events to a button.
Best wishes,
Yana
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items