Odd RadButton client-side behavior

4 posts, 0 answers
  1. Boris
    Boris avatar
    276 posts
    Member since:
    Oct 2012

    Posted 12 Feb 2013 Link to this post

    (This is probably silly.)  

    I was looking at refreshing the screen in Javascript.  I've not used that reload command before.  I put the following button on my screen.

    <telerik:RadButton ID="RadButton1" runat="server" AutoPostBack="False" Text="test" OnClientClicked="window.location.reload(true)">
                                 </telerik:RadButton>

    Now it looks like that OnClientClicked is continuously firing. 
  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 13 Feb 2013 Link to this post

    Hi Boris,

    This is an odd result to get for what you had written. I moved the window.location.reload into a js function and the button works as intended. I still have no idea why the OnClientClicked event would keep firing like that. Take a look:
    <script type="text/javascript">
            function reloadThis(){
                alert("Reloading");
                window.location.reload(true);
            }
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
    <telerik:RadButton ID="RadButton1" runat="server" Text="test" AutoPostBack="False"
                 OnClientClicked="reloadThis"></telerik:RadButton >


    Hopefully this helps, 
    Master Chief
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boris
    Boris avatar
    276 posts
    Member since:
    Oct 2012

    Posted 13 Feb 2013 Link to this post

    Actually this is now academic since I used a different scenario, but still curious.
  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 15 Feb 2013 Link to this post

    Hi Boris,

    You can check the difference between ASP button and RadButton client-side event handling in this help article. If you do not pass a function name to the property OnClientClicked as it is done in the code sample from the first post, the client-side object of the button will not be created correctly. This will result in a JavaScript error, which in your case causes the constant execution of the page reload.

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