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

Change text of RadButton on client-side with JavaScript

2 Answers 926 Views
Button
This is a migrated thread and some comments may be shown as answers.
Amy
Top achievements
Rank 1
Amy asked on 04 Apr 2011, 09:38 PM
Hi!  Could someone provide me an example of how to change the text of a RadButton using JavaScript?  Basically when a user clicks the 'submit' button I want to display an alert message, disable the button, and change the text to say 'Submitting'.  I've got the alert message working, but the button text doesn't appear to change nor is it disable.

Here's the lines of code for the javascript...
<telerik:RadCodeBlock ID="rcb1" runat="server">
    <script type="text/javascript">
        function DisableSubmitBtn() {
            alert("Submitting Review, please do not click submit more than once");
            document.getElementById('<% =btnItemSubmitE.ClientId %>').value = 'Submitting'; 
           
        }
    </script>
</telerik:RadCodeBlock>

Here's the button code...
<telerik:RadButton ID="btnItemSubmitE" runat="server" Skin="Sunset" Text="Submit"
                            Width="45%" ValidationGroup="Review" OnClientClicked="DisableSubmitBtn" >
                            <Icon PrimaryIconCssClass="rbOk" PrimaryIconLeft="4" PrimaryIconTop="4" />
                        </telerik:RadButton>


There are validation controls on the page and a RadAjaxManager is being used.

Thank you!

2 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 05 Apr 2011, 05:27 AM
Hi Amy,

The set_text(textToSet) client-side method should be used to set the button's text on the client. Basically your JS code will look like the following:
<script type="text/javascript">
function DisableSubmitBtn() {
   alert("Submitting Review, please do not click submit more than once");
   $find('<% =btnItemSubmitE.ClientId %>').set_text("Submitting");          
}
</script>

A list of RadButton's client-side methods and properties can be found on the following link: http://www.telerik.com/help/aspnet-ajax/button-client-side-basics.html.

An example showing a "Single click" button can be found on our online demos site.

Best wishes,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Amy
Top achievements
Rank 1
answered on 05 Apr 2011, 01:33 PM
Pero, thank you!  That worked wonderfully, and I've bookmarked the link you provided.  ;-)

Thanks again!
Tags
Button
Asked by
Amy
Top achievements
Rank 1
Answers by
Pero
Telerik team
Amy
Top achievements
Rank 1
Share this question
or