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

Does set_text() in the client API persist to the server?

1 Answer 64 Views
Button
This is a migrated thread and some comments may be shown as answers.
Joel Kraft
Top achievements
Rank 2
Joel Kraft asked on 04 Aug 2011, 08:50 PM
Hi,

I was wondering if the set_text() client API call is intended to persist that value to the server on a postback.  I am working on an adaptation of the single-click button example in the demonstrations.  In the sample, the button text is set to something like "Processing..." in the OnClientClicked event, and then is returned to the previous value by the OnReponseEnd function of the RadAjaxManager.

The example we are trying to write is not Ajax enabled, so we expect the button to be placed back to its original value by virtue of the postback resetting the value to whatever was defined on the server side.  We have been using this method with a standard ASP button that works fine when setting the .value property on the client side.

Using RadButton, though, setting set_text() appears to persist this value back to the server, and so then it is not changed back to the server-defined value when the post refreshes.  Is there a way to keep that value from being posted back to the server or some other workaround?

Thanks,
Joel

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 05 Aug 2011, 01:17 PM

Hello Joel,

One of the ways that I've implemented the single-click button is like so:

RadButton Markup:

<telerik:RadButton ID="btnSave" runat="server" Text="Submit Request" ToggleText="Submit Request|Submitting Request..."
                OnClientLoad="btnSingleClick_OnClientLoad" OnClientClicked="btnSingleClick_OnClientClicked"
</telerik:RadButton>

Javascript:
function btnSingleClick_OnClientLoad(sender, args) {
    try {
        // set text when to first entry in array
        sender.set_text($telerik.$(sender.get_element()).attr("ToggleText").split("|")[0]);
    } catch (e) { }
}
function btnSingleClick_OnClientClicked(sender, args) {
    try {
            // disable control
            sender.set_enabled(false);
            // toggle text to second entry in array
            sender.set_text($telerik.$(sender.get_element()).attr("ToggleText").split("|")[1])
    
    catch (e)
    {
    }
}

So as you can see I add a ToggleText property to my RadButton listing the text that it should show when not clicked and clicked. I then use the OnClientLoad event to load the not clicked text and handle the OnClientClicked event to show the clicked text.

I hope that helps.
Tags
Button
Asked by
Joel Kraft
Top achievements
Rank 2
Answers by
Kevin
Top achievements
Rank 2
Share this question
or