OnClientClicked event in code behind

4 posts, 0 answers
  1. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 29 Jun 2012 Link to this post

    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.
  2. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 03 Jul 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 03 Jul 2012 Link to this post

    I opened a support ticket. I'll post the solution here if Telerik can find it.

    Thanks for your reply.
  5. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 03 Jul 2012 Link to this post

    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!
Back to Top