button.click different than clicking on button

4 posts, 0 answers
  1. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 11 Oct 2012 Link to this post

    I have a rad button which implements the single click solutoin provided by Telerik to pervent multiple submissions.

    My declaration is:

    <telerik:RadButton ID="btnFind" runat="server" Text="Find Visits" style="margin:7px;" UseSubmitBehavior="false" OnClientClicked="FindClickedHandler_VFC">
                                    <Icon PrimaryIconUrl="~/global/images/icons/search.png" />
                                </telerik:RadButton>


    And I have a handler for the OnClientClicked Event:

    function FindClickedHandler_VFC(sender, eventArgs) {
     
                var validated = Page_ClientValidate('val');
                if (!validated) {
                    return;
                }
                else {
                    sender.set_enabled(false);
                    if (sender.get_text() == "Search") sender.set_text("Searching...");
                }
            }


    When I click on the button, everything works as expected. However, in some instances, I would like to induce the button click and have it do exactly the same from some client-side code. When I call the button.click function client-side I have noticed that the cliked handler does fire, but the postback never occurs. I am guessing this has something to do with the removal of the postback behavior in the button which is necessary to prevent the double click. Is there a way to make the button do the same thing whether you click on it or call button.click client-side?

  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 16 Oct 2012 Link to this post

    Hi Albert,

    I tried to reproduce the problem you encountered, but to no avail. You can find attached my test page. Please compare it with your actual project and check if there are differences in the setup. This screen capture displays the behavior on my end.

    I would suggest checking if you are canceling the postback of the RadButton somewhere in your script, for example by calling the method set_autoPostBack(false) or set_cancel(true) in the handler of the OnClientClicking event.

    Note that I am mostly guessing as to what your actual setup is. If the problem persists, please open a regular support ticket and try modifying the attached sample so that it matches your case. If this is not possible you can also prepare and send a simple, fully runnable page that isolates the issue, which will allow me to inspect it locally and provide a more to the point answer.

    Kind 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. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 16 Oct 2012 Link to this post

    In my app, the radbutton is inside a panel which is ajaxified (the panel is the initiator and updated control). I also have an ajax setting where the rad button is the initiator and a second panel is the updated control. Can you make these two ajax modifications to your sample and see if it still works prior to my trying to create a stripped-out example?
  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 19 Oct 2012 Link to this post

    Hello Albert,

    I updated my sample according to your description, but I still cannot reproduce the problem. Please check the attached page and let me know if I have missed something.

    The problem you encountered could also be result of a JavaScript error that occurs when an Ajax request is initiated. You can use the console of your browser's developer tools to ensure if this is the case.

    If you are still having difficulties, please send a modified version of the provided sample or a simple, runnable page that isolates the issue. This way I can reproduce the problem locally and suggest 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.
Back to Top