On page load RadButton Onclientclicked triggered
asp.net, c#, telerik
Solution
Couple of things here. The difference between a RadButton and a normal HTML button is as follows:
When a RadButton is used, the client side HTML generated is as follows:
<a id="btnStandard" class="RadButton RadButton_Office2010Silver rbSkinnedButton"
href="javascript:void(0)">
<input class="rbDecorated" type="submit" name="btnStandard_input"
id="btnStandard_input" value="Standard Button" />
<input id="btnStandard_ClientState" name="btnStandard_ClientState"
type="hidden" />
</a>
As you can see, the type generated is of "Submit" - which means it will submit the form to the server. So if you refresh it will try to resend the form again. what i am failing to understand is - have you used ajax panel. Because if you have used ajax panel, the button click would trigger an ajax posting to the server and when you refresh the page its as if its a first time and not a postback.
Where as the normal html is not meant for form submits. Its just used to trigger a click event on the client side.
Having said that - the signature for OnClientChecked is as follows:
OnClientChecked="<js function name>"
NOTE: you should be providing only the function name without parenthesis i.e. ( and ).
In your case since you provided the parenthesis - when the button gets initialized the client side functions associated with it are getting executed and you are having your Javascript code run at runtime.
So here is the right code for this:
<telerik:RadButton runat="server" Text="test" OnClientClicked="func" />
<script>
function func() {
alert("clicked");
}
</script>
Hope this answers your question.
Problem
When I use telerik radbutton ``` <telerik:RadButton ID="RadButton1" runat="server" Text="Stackoverflow" Skin="Default" OnClientClicked="SaveIt()" CommandArgument="Edit"> </telerik:RadButton> ``` after refreshing page, always SaveIt() function starts to work. But; when I use button, it works only when user click it. ``` <button type="button" onclick="SaveIt()">Stackoverflow</button> ``` What is the difference between them?