Odd RadButton client-side behavior

4 posts, 0 answers
  1. Boris
    Boris avatar
    289 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)">

    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(){
    <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. Boris
    Boris avatar
    289 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.
  4. Slav
    Slav avatar
    1359 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.

    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