troubleshooting Question

Reduce amount of data transferred during a partial render of a web page

Avatar of Staudte
StaudteFlag for Germany asked on
Microsoft IIS Web ServerASP.NETVisual Basic.NET
5 Comments1 Solution598 ViewsLast Modified:
Dear experts,

I'm developing a web-application that will display data derived from a database. As soon as the database was updated (elsewhere on the network) the page should refresh. As I've not found a way to trigger a page refresh from the server side, I have created two updatepanels: one with a timer that periodically checks for updates and one with the label containing the output. Only when the procedure triggered by the timer detects an update in the database, the output panel gets updated.

That in itself is working fine. However, the whole page gets transferred every time the timer triggers, including the lengthy output (which was unchanged) - I have cked that with chrome's "inspect element" function and the network timeline. The update panels got rid of the flickering of a full-refresh of the screen, but as the page will be displayed on a mobile device, data transfer volume must be kept low.

Is there a way I can either trigger the update from the server's end or reduce the amount of data transferred? (Ideally there would only be a few bytes if there was no change.)

The sample project is below.

Thank you for sharing your wisdom :-)

Imports Microsoft.VisualBasic
Imports System
Imports System.Web.UI

Public Class _default
    Inherits System.Web.UI.Page

    Protected Sub timerUpdate_Tick(sender As Object, e As EventArgs) Handles timerUpdate.Tick
        Dim s As String

        ' At this point s would actually be created from a database.
        ' Unless there was a change in the database, s will remain the same in each iteration
        s = String.Concat(Enumerable.Repeat("abc ", 10000))

        ' The right-business is only to remove the timestamp, which is only used anyway in this test
        ' Usually the code would be
        ' If s <> lbl1.Text Then
        '     lbl1.Text = s
        '     UpdatePanel.Update()
        ' End If
        If s <> Right(lbl1.Text, Len(s)) Then
            lbl1.Text = Now.ToString & " " & s
        End If

    End Sub
End Class

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <form id="form1" runat="server" title=" ">
        <asp:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel runat="server" ID="TimerPanel" UpdateMode="Conditional">
                <asp:Timer runat="server" ID="timerUpdate" Interval="2000" OnTick="timerUpdate_Tick"></asp:Timer>
        <asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional">
                <asp:Label ID="lbl1" runat="server" text="not updated yet"/>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros