asp.net 2.0中 updatepannel(1)

來源:互聯網
上載者:User
1 當一個控制項放在updatepanne外時,如果依然要用ajax的功能的話,可以這樣搞,
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.ScriptManager1.RegisterAsyncPostBackControl(Me.Button1)
    End Sub
即用代碼的方式註冊這個控制項

2  updatepanel 的updatemode屬性設定
    比如
   <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="UpdatePanel1中的按鈕" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="UpdatePanel2中的按鈕" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:Button ID="Button3" runat="server" Text="不在UpdatePanel中的按鈕" /></div>

    A  當頁面上有多個updatepannel時,如果updatemode屬性設定為always,則會被任何的非同步postback
所重新整理,若updatemode屬性設定為conditional,則只會被位於該updatepannel自己內部的控制項所觸發更新。
   比如上面,將updatepannel2的屬性改為conditional,則updatepanel1中的更新不會反映到控制項2中去。
但updatepannel2中的POSTABACKG更新也會反映到1中去,也就是說,如果設定為always的話,
則可以認為是最敏感的了,響應任何更新,即使是在任何updatepannel下的

  B 如果要將updatepannel控制項外的控制項設定為可觸發,可通過該updatepannel的triggers屬性將控制項設定
為asyncpostbacktrigger,如果要設定為不可觸發,則設定為postbacktrigger
 C 同樣,要達到B的效果,但用代碼的話,設定為可觸發,用registerasyncpostbackcontrol
取消則用registerpostbackcontrol

  

   

聯繫我們

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