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

OnClientClicked event in code behind

3 Answers 279 Views
Button
This is a migrated thread and some comments may be shown as answers.
Jocelyn
Top achievements
Rank 1
Jocelyn asked on 29 Jun 2012, 01:21 PM
Hi,

I have a simple button that I create at runtime.

Dim btn as New RadButton()
btn.AutoPostBack = False
btn.OnClientClicked = "BtnClicked"


function BtnClicked(sender, args)
{
       alert("Hey!");
}

When I click on the button, BtnClick is not fired. What is wrong my code?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 03 Jul 2012, 12:28 PM
Hello Jocelyn,

The code that you have provided appears to be valid. Most probably there is a JavaScript error that is breaking the client-side event handling of RadButton. Also, you can verify that the handler method is declared on the actual page in which the button control is added.

This online demo Button / Client-side Events shows the RadButton client-side events. You can use it as a reference for handling the OnClientClicked event on your end.

If you are still having difficulties, please open a support ticket and send a simple, runnable page that isolates your case so that I can inspect it locally and provide an according solution.

Regards,
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
Jocelyn
Top achievements
Rank 1
answered on 03 Jul 2012, 12:52 PM
I opened a support ticket. I'll post the solution here if Telerik can find it.

Thanks for your reply.
0
Jocelyn
Top achievements
Rank 1
answered on 03 Jul 2012, 02:09 PM
My mistake was that I was adding my button like this:

Me.Controls.Add(test)

But I must add my button inside the form like this:

Me.Form.Controls.Add(test)

Thanks for your help!
Tags
Button
Asked by
Jocelyn
Top achievements
Rank 1
Answers by
Slav
Telerik team
Jocelyn
Top achievements
Rank 1
Share this question
or