<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  private void UpdateContents(object o, EventArgs e)
  {
    if (new Random().Next(0, 4) == 1)
    {
      UpdatePanel1.Update();
    }
  }

  protected void Page_Load(object sender, EventArgs e)
  {
    CurrentTime.Text = DateTime.Now.ToLongTimeString();
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
  <title>ASP.NET AJAX</title>
</head>
<body>
  <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"
      UpdateMode="Conditional">
      <ContentTemplate>
        <asp:Timer ID="FiveSeconds" Interval="5000"
          OnTick="UpdateContents"
          runat="server" />
        <asp:Label ID="CurrentTime" runat="server" />
      </ContentTemplate>
    </asp:UpdatePanel>
  </form>
</body>
</html>
