Autosave form every x seconds?

6 posts, 0 answers
  1. Chris May
    Chris May avatar
    31 posts
    Member since:
    Nov 2009

    Posted 02 Mar 2011 Link to this post

    What I'd like to do, is asynchronously post back my form and save the data every X seconds.

    I know I can do this with javascript if I iterate my controls and build up some kind of comma separated string holding all the form values and send that to the server as a page method call, but because the form is quiet complicated (nested data lists and grid views), it would be much easier if I could just write the "Save" logic 1 time in the code behind (when the user clicks "Done") and reuse that same code for the auto save.

    I was thinking maybe I could somehow use the rad ajax manager to cause an async postback of the page that the user wouldn't notice, and it wouldn't update any controls.

    Is this possible?
  2. Tsvetina
    Admin
    Tsvetina avatar
    1874 posts

    Posted 08 Mar 2011 Link to this post

    Hi Chris,

    A simple solution in this scenario would be to add an asp Timer wrapped in a RadAjaxPanel control on your page and save your data in the OnTick event of the timer. If the timer is the only control wrapped in the panel, nothing will be refreshed on your page during the callbacks that it makes.

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" >
        <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="3000" />
    </telerik:RadAjaxPanel>

    Greetings,
    Tsvetina
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Markus Ruf
    Markus Ruf avatar
    29 posts
    Member since:
    Dec 2008

    Posted 05 Jan 2015 in reply to Tsvetina Link to this post

    Hello Tsvetina

    I have a similar problem. After saving the page every few minutes, the page return to the top of the page and the focus is lost from the currently editing field.
    Inserting the timer alone in a separate updatePanel (PanelAutoSave, after PanelContent) didn't solve the problem.

    In my scenario (Version 2013.3.1324.35  on .Net 3.5) I'm using a MasterPage. So I register the AJAX event in the ServerSide-Code of the page:
       myMaster.masterAjaxManager.AjaxSettings.AddAjaxSetting(PanelContent, PanelContent, LoadingPanel);
       myMaster.masterAjaxManager.AjaxSettings.AddAjaxSetting(Timer1, PanelAutoSave);

    The page itself contains dynamically added TextBoxes and other controls (no RadEditor), all in one Panel (PanelContent)). Both panels are inside the  <asp:Content ContentPlaceHolder...></Content>.
    Is the MasterPage the problem, or is it the dynamically builded Panel which is rebuild every Postback, or is there something else I'm missing?

    Thanks for your suggestion
    Markus
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 07 Jan 2015 Link to this post

    Hi Markus ,

    Note that by default RadAjaxPanel maintains the focus of the AJAX-ified control when the response ends. Therefore instead of using RadAjaxManager to ajaxify the controls on the page please remove the RadAjaxManager and wrap the whole content in RadAjaxPanel and verify how it goes.

    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Markus Ruf
    Markus Ruf avatar
    29 posts
    Member since:
    Dec 2008

    Posted 12 Jan 2015 in reply to Maria Ilieva Link to this post

    Hello Maria

    Thanks for your answer.

    What I now did:
    I removed the registration of all controls (the two panels) on this page to the Masterpage-RadAjaxManager.
    I left the timer in a separate Panel, and the dynamic controls stayed in an other Panel.
    Now it works without jumping to the top of the page and it is not longer loosing the focus when a auto-save occurs.
    Thanks.

    Kind regards
    Markus
  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 14 Jan 2015 Link to this post

    Hello Markus,

    Thank you for getting back to us and for providing the updates on this case.

    Do not hesitate to open a new form thread or a support ticket in case further assistance is needed.

    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017