jQuery實現局部重新整理頁面資料繫結

來源:互聯網
上載者:User

標籤:style   blog   class   code   java   ext   

今天遇到了一個問題:怎麼樣才能做到只重新整理頁面中的Repeater控制項中的資料,在不用UploadPannel的情況下?

試了好多方法,無意間在看jquery檔案時發現,使用load()方法即可解決此問題。

代碼如下:

<html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server">    <title>當前頁(WebForm1.aspx)局部資料重新整理</title>    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>    <script type="text/javascript">        function sdf() {            var parendtId = $("#DropDownList1 option:selected").val();            $("#dataDiv").load("WebForm1.aspx #dataDiv", { parendtId: parendtId, R: Math.random() }, function () { $("#dataDiv").fadeIn(10000000); });        }    </script></head><body>    <form id="form1" runat="server">    <div>        <div>            <asp:DropDownList ID="DropDownList1" runat="server">            </asp:DropDownList>            <input type="button" id="refreshData" onclick="sdf();" value="重新整理" />            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>            <asp:Button ID="Button1" runat="server" Text="Button" />        </div>        <div id="dataDiv">            <asp:Repeater ID="Repeater1" runat="server">                <HeaderTemplate>                    <table border="1" cellpadding="0" cellspacing="0" width="100%">                        <tr class="bold">                            <th style="color: Black; font-weight: bold; width: 30%">                                所屬分類                            </th>                            <th style="color: Black; font-weight: bold; width: 30%">                                分類名稱                            </th>                            <th style="color: Black; font-weight: bold; width: 10%">                                狀態                            </th>                        </tr>                </HeaderTemplate>                <ItemTemplate>                    <tr>                        <td>                            <%#Eval("Pid")%>                        </td>                        <td>                            <%#Eval("Name")%>                        </td>                        <td>                            <%#Eval("Status")%>                        </td>                    </tr>                </ItemTemplate>                <FooterTemplate>                    </table>                </FooterTemplate>            </asp:Repeater>        </div>    </div>    </form></body></html>


從實現代碼大家可以看出,其實使用jquery的load()方法實現的原理就是:重新載入當前頁面中指定地區的所有資訊。

注意:它會引起頁面回傳。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.