Autosave in ASP.NET Web Forms: The Timer Is Not the Save Contract

Editorial illustration.

Originally published 16 June 2023; rewritten and reviewed on 15 October 2026.

Long enterprise or government portal forms—like grant applications, vendor registrations, or multi-section claims—give users plenty of chances to lose 20 minutes of typing to a flaky Wi-Fi connection or an accidental browser refresh. Back when I maintained legacy ASP.NET Web Forms portals, the quickest way to add autosave without rewriting the whole page in JavaScript was pairing an asp:Timer with an asp:UpdatePanel.

That combination still shows up in older .aspx codebases today. The catch is that wiring up a timer tick is only the transport mechanism; if you treat the tick itself as your save logic, you end up with partial validation errors, stale overwrites, and bloated ViewState round-trips.

Understand what the partial postback actually sends

An asp:Timer inside an UpdatePanel does not magically send a tiny JSON payload of changed fields. It triggers a full asynchronous postback of the form, including ViewState, through ScriptManager. If your page holds large GridView controls or heavy dropdowns, a 15-second timer interval will hammer both the client network and IIS worker threads.

Keep the UpdatePanel scoped narrowly with UpdateMode="Conditional" and set CausesValidation="false" on the timer or trigger so incomplete required fields do not block draft saves:

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<asp:UpdatePanel ID="upAutosave" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Timer ID="tmrAutosave" runat="server" Interval="30000" OnTick="tmrAutosave_Tick" />
        <asp:Label ID="lblSaveStatus" runat="server" CssClass="text-muted" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="tmrAutosave" EventName="Tick" />
    </Triggers>
</asp:UpdatePanel>

On the server side, the Tick handler runs during the standard Web Forms page lifecycle (Page_Load executes first, then tmrAutosave_Tick). Any dynamically created controls must be recreated in Page_Init or Page_Load, otherwise their posted values will be missing when the handler reads them.

protected void tmrAutosave_Tick(object sender, EventArgs e)
{
    if (!User.Identity.IsAuthenticated || !IsDirty())
        return;

    var draftId = Convert.ToInt32(hfDraftId.Value);
    var expectedVersion = Convert.ToInt32(hfRowVersion.Value);

    var saved = _draftService.TrySaveDraft(draftId, CurrentUserId(), ReadFormFields(), expectedVersion, out int newVersion);
    if (!saved)
    {
        lblSaveStatus.Text = "Draft modified in another tab. Refresh before saving.";
        tmrAutosave.Enabled = false;
        return;
    }

    hfRowVersion.Value = newVersion.ToString();
    lblSaveStatus.Text = $"Draft saved at {DateTime.Now:HH:mm:ss}";
}

Notice the IsDirty() check and expectedVersion guard. Without them, a user who opens the same application in two browser tabs will silently overwrite newer edits in Tab A with older state from Tab B every 30 seconds.

Separate drafts from final submissions

A draft is allowed to be messy. A user might type a project title and paste half a budget table before walking away for lunch. Your final Submit button should belong to a dedicated ValidationGroup (e.g., ValidationGroup="FinalSubmit") that enforces mandatory fields, attachment checks, and business rules—while the autosave path persists to a Drafts table or a Status = 'Draft' record without triggering downstream workflows like email notifications or payment gateways.

One subtle side effect of asp:Timer in Web Forms is that each partial postback slides the ASP.NET Session timeout window forward. If your security policy expects idle sessions to expire after 20 minutes, an unattended browser tab ticking every 30 seconds will keep the session alive indefinitely unless you track real user input timestamps or disable the timer after a set number of ticks without field changes.

Make the status indicator honest

Only update lblSaveStatus after the database transaction commits. Showing “Saved” when the request merely fired—or swallowing SQL exceptions inside an empty catch block—gives users false confidence right before they close the tab. Display the exact timestamp of the last confirmed save, and if a network drop happens, show a clear retry notice rather than failing silently.

Images from the original article

The following images are retained as historical context; interfaces and configuration options may have changed.

Original article image 1: Autosave in ASP.NET Web Forms: The Timer Is Not the Save Contract