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

2 posts, 0 answers
  1. Joel Kraft
    Joel Kraft avatar
    87 posts
    Member since:
    Jan 2004

    Posted 04 Aug 2011 Link to this post

    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
  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 05 Aug 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top