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

Odd RadButton client-side behavior

3 Answers 57 Views
Button
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 12 Feb 2013, 03:27 PM
(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. 

3 Answers, 1 is accepted

Sort by
0
MasterChiefMasterChef
Top achievements
Rank 2
answered on 13 Feb 2013, 06:50 PM
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
0
Boris
Top achievements
Rank 1
answered on 13 Feb 2013, 07:03 PM
Actually this is now academic since I used a different scenario, but still curious.
0
Slav
Telerik team
answered on 15 Feb 2013, 12:32 PM
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.
Tags
Button
Asked by
Boris
Top achievements
Rank 1
Answers by
MasterChiefMasterChef
Top achievements
Rank 2
Boris
Top achievements
Rank 1
Slav
Telerik team
Share this question
or