c# asp:UpdatePanel 和 asp:Repeater實現頁面局部資料無重新整理取得

來源:互聯網
上載者:User

 一、首先在web.config檔案中添加如下內容。(不添加下面的內容實現不了重新整理局部頁面的效果)

    <httpHandlers>       
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>



二、 <asp:SrciptManager> 控制項一定要緊跟在<form>後面

三、bin檔案夾裡必須有下面三個檔案的引用

他們所在的檔案夾位置是
C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025

AJAXExtensionsToolbox.dll
System.Web.Extensions.Design.dll
System.Web.Extensions.dll

四、測試代碼檔案如下:

    .cs檔案load事件代碼

protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            System.Threading.Thread.Sleep(2000);//延遲回應時間
        }
        DataTable dt = new DataTable();
    
        dt.Columns.Add(new DataColumn("Name"));
        dt.Columns.Add(new DataColumn("sex"));
        dt.Columns.Add(new DataColumn("DateTime"));
        for (int i = 0; i < 5; i++) {
            DataRow dr = dt.NewRow();
            dr["Name"] = "http://www.my400800.cn";
            dr["sex"] = "男";
            dr["DateTime"] = Convert.ToString(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            dt.Rows.Add(dr);
        }

        gv_detailList.DataSource = dt;
        gv_detailList.DataBind();
    }

.aspx檔案內容

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewDrillDownjQueryAjax.aspx.cs" Inherits="GridViewDrillDownjQueryAjax" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>JQuery Demo(http://www.my400800.cn)</title>   
</head>
<body>
    <form id="form1" runat="server">

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

  
        <asp:UpdateProgress ID="listDetailPress" runat="server" AssociatedUpdatePanelID="UpdatePanelGridDetail" >
            <ProgressTemplate>
                <img src="../../img/progress-indicator.gif" />資料載入中,請稍後
            </ProgressTemplate>
        </asp:UpdateProgress>
     
        <asp:UpdatePanel ID="UpdatePanelGridDetail" runat="server">
            <ContentTemplate>
                <asp:Repeater ID="gv_detailList" runat="server">
                <HeaderTemplate>
                <table style="width: 100%">
                </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td rowspan="3" style="width: 10%">
                            </td>
                            <td style="text-align: left">
                                <%#Eval("Name").ToString()%></td>
                            <td rowspan="3" style="width: 100px">
                                <%#Eval("Sex").ToString()%>
                            </td>
                        </tr>
                        <tr>
                            <td style="height: 18px; text-align: left;">
                                Summary</td>
                        </tr>
                        <tr>
                            <td>
                               
                                    發送時間<%#Eval("DateTime").ToString()%>  來源 評價
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                    </table>
                   
                
                  <asp:LinkButton ID="LinkButton1" runat="server" >重新整理</asp:LinkButton>
                    </FooterTemplate>
                </asp:Repeater>
            </ContentTemplate>
        </asp:UpdatePanel>

    </form>
</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.