我在模板页里面加了scriptmanager 和一个updatepanl希望能够在内容也里面实现局部刷新。但是事实上 在现实上没有任何效果还是 整页刷新以下是主要代码:
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                        </asp:ContentPlaceHolder>
                    </ContentTemplate>
                   
                </asp:UpdatePanel>

解决方案 »

  1.   

    设置UpdateMode属性
    设置表示UpdatePanel的更新模式,有两个选项:Always和Conditional。Always是不管有没有Trigger,其他控件都将更新该UpdatePanel,Conditional表示只有当前UpdatePanel的Trigger,或ChildrenAsTriggers属性为true时当前UpdatePanel中控件引发的异步回送或者整页回送,或是服务器端调用Update()方法才会引发更新该UpdatePanel。
      

  2.   

    楼上已经给你说了。我贴一个demo,如果你说“仍然不行”,我觉得你就格式化你的电脑算了:<%@ Page Language="C#" %><script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Calendar1.Style["position"] = "absolute";
                this.TextBox1.DataBind();
            }
        }    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DropDownList2.Items.Clear();
            switch (this.DropDownList1.SelectedValue)
            {
                case "北京":
                    this.DropDownList2.Items.Add("天安门广场");
                    this.DropDownList2.Items.Add("颐和园");
                    this.DropDownList2.Items.Add("雍和宫");
                    this.DropDownList2.Items.Add("红螺寺");
                    break;
                case "上海":
                    this.DropDownList2.Items.Add("崇明岛");
                    this.DropDownList2.Items.Add("外滩");
                    this.DropDownList2.Items.Add("万佛阁");
                    break;
                case "香港":
                    this.DropDownList2.Items.Add("海洋公园");
                    this.DropDownList2.Items.Add("半岛酒店");
                    break;
            }
        }
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            ShowResult();
        }    protected void Button1_Click(object sender, EventArgs e)
        {
            if (this.Calendar1.Visible)
                SetupTheDate();
            else
            {
                try
                {
                    this.Calendar1.SelectedDate = DateTime.Parse(this.TextBox1.Text);
                    this.Calendar1.VisibleDate = this.Calendar1.SelectedDate;
                }
                catch
                {
                }
                this.Calendar1.Visible = true;
            }
        }    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            SetupTheDate();
        }    private void SetupTheDate()
        {
            this.TextBox1.Text = this.Calendar1.SelectedDate.ToShortDateString();
            this.Calendar1.Visible = false;
            ShowResult();
        }    void ShowResult()
        {
            this.Label1.Text = "您选择" + this.TextBox1.Text + "去" + this.DropDownList2.SelectedValue;
            UpdatePanel3.Update();
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <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:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                    <asp:ListItem>--请选择--</asp:ListItem>
                    <asp:ListItem>北京</asp:ListItem>
                    <asp:ListItem>上海</asp:ListItem>
                    <asp:ListItem>香港</asp:ListItem>
                </asp:DropDownList>
                <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        <table border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    请输入日期:
                </td>
                <td>
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <asp:TextBox ID="TextBox1" runat="server" Width="147px" Text="<%# DateTime.Now.AddDays(20).ToShortDateString() %>" />
                                        <asp:Button ID="Button1" runat="server" Text="..." OnClick="Button1_Click" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Calendar ID="Calendar1" runat="server" Visible="False" OnSelectionChanged="Calendar1_SelectionChanged"
                                            BackColor="#FFFFCC" BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest"
                                            Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="200px" ShowGridLines="True"
                                            Width="220px">
                                            <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
                                            <SelectorStyle BackColor="#FFCC66" />
                                            <TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
                                            <OtherMonthDayStyle ForeColor="#CC9966" />
                                            <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
                                            <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
                                            <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" ForeColor="#FFFFCC" />
                                        </asp:Calendar>
                                    </td>
                                </tr>
                            </table>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
        <hr />
        <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                result:
                <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Size="Small"></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>
        </form>
    </body>
    </html>
      

  3.   

    楼上不是说楼主,另外,楼主,你的代码不能实现局部刷新,该页面如果是top,则实现"伪无刷"效果,如果是child,你的代码等于没用
      

  4.   

    实在不行啊 我建网站的时候用vs10选的版本是.net2.0 ajax是我后来装的版本,我怎么试也木有结果 我都崩溃了
      

  5.   


    是这样的我 重新写了一个页面上面就只有 一个scriptmanager updatepanl 和一个button,我为了测试这么写的:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %><%@ Register assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
                </ContentTemplate>
            </asp:UpdatePanel>
        
        </div>
        </form>
    </body>
    </html>调试时依然让我失望  哎。。
      

  6.   

    楼主看看这个吧,但愿能对你有用
    http://www.cnblogs.com/Terrylee/archive/2006/11/13/using_the_updatepanel_control_with_master_pages.html
      

  7.   

    你为什么会使用“System.Web.Extensions, Version=1.0.61025.0”呢?asp.net ajax正式发布,是在.net 3.5sp1中的事情。不要用什么 1.0.61025.0 额外补丁,用.net中自己带的。正式的System.Web.Extensions的版本至少是2.xxx以上的。
      

  8.   

    事实上 这个blog我已经看了几遍了 我想问问上面我贴的这个代码 应该没问题吧
      

  9.   

    这里是MSDN的文章:
    http://msdn.microsoft.com/zh-cn/library/bb398864.aspx
      

  10.   

    但是2.0环境里面是不自带ajax的呀
      

  11.   

    .net2.0不妨碍你使用最新的ajax组件,
    比如,下载一个AjaxControlToolkit.dll
    然后,在webconfig中的<controls>节中添加:
    <add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit" />页面中使用这个:<ajaxToolkit:ToolkitScriptManager ID="Tsm1" runat="server"></ajaxToolkit:ToolkitScriptManager>你原来html第一行的注册语句可以不需要了
      

  12.   

    不过不要忘了在web项目中添加dll引用
      

  13.   

    你web.config里配置ajax的东东了么?
      

  14.   

    向页面添加ajax控件的时候会自动向web.config添加 配置