Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.








UpdatePanelTutorial17 Sample


<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">
    protected void NewsClick_Handler(object sender, EventArgs e)
        HeadlineList.DataSource = GetHeadlines();
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            HeadlineList.DataSource = GetHeadlines();
    // Helper method to simulate news headline fetch.
    private SortedList GetHeadlines()
        SortedList headlines = new SortedList();
        headlines.Add(1, "This is headline 1.");
        headlines.Add(2, "This is headline 2.");
        headlines.Add(3, "This is headline 3.");
        headlines.Add(4, "This is headline 4.");
        headlines.Add(5, "This is headline 5.");
        headlines.Add(6, "(Last updated on " + DateTime.Now.ToString() + ")");
        return headlines;

<html xmlns="">
<head runat="server">
    <title>Canceling Postback Example</title>
    <style type="text/css">
    body {
        font-family: Tahoma;
       width: 400px;
       height: 200px;
       border: solid 1px gray;
    div.AlertStyle {
      font-size: smaller;
      background-color: #FFC080;
      width: 400px;
      height: 20px;
      visibility: hidden;
    <form id="form1" runat="server">
        <div >
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <asp:ScriptReference Path="CancelPostback.js" />
        <asp:UpdatePanel  ID="UpdatePanel1" runat="Server" >
                <asp:DataList ID="HeadlineList" runat="server">
                         <%# Eval("Value") %>
                    <FooterStyle HorizontalAlign="right" />
                <p style="text-align:right">
                <asp:Button ID="RefreshButton" 
                            OnClick="NewsClick_Handler" />
                <div id="AlertDiv" class="AlertStyle">
                <span id="AlertMessage"></span> 
                <asp:LinkButton ID="CancelRefresh" runat="server">