Change does not persist after a postback

2 posts, 1 answers
  1. JC
    JC avatar
    30 posts
    Member since:
    Feb 2013

    Posted 25 Feb 2013 Link to this post

    Hi,

    There is a RadTabStrip control in my user home page and I want to add a new tab to it using Javascript. I am able to add a new tab but the issue is that the change is not persisting after some postback is made. Am I missing something to save the change? Please help.

    Thanks,
    JC.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Feb 2013 Link to this post

    Hello JC,

    I believe you are not using the trackChanges and commitChanges client side methods. Client side changes are available on the server side after postback but only changes to the tabs that occur between a call to trackChanges and commitChanges persist after a postback.

    Please have a look at the following code which works fine at my end. I am adding tabs to RadTabStrip on clicking a RadButton using client side code.

    ASPX:
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" Skin="WebBlue">
        <Tabs>
            <telerik:RadTab runat="server" Text="Telerik">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="ASP">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Text="Ajax">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Add Tab" OnClientClicked="AddTab"></telerik:RadButton>

    JavaScript:
    <script type="text/javascript">
        function AddTab(sender, args) {
            var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
            var tab = new Telerik.Web.UI.RadTab();
            tab.set_text("New Tab");
            tabStrip.trackChanges();
            tabStrip.get_tabs().add(tab);
            tabStrip.commitChanges();
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top