ScriptManager和UpdatePanel控制項

來源:互聯網
上載者:User

在Ajax中當你要使用updatepanel控制項時,首先要先拖一個scriptmanager控制項。

  在updatepanel中updatemode與ChildrenAsTriggers怎樣組合才不衝突呢?

       UpdateMode =Always    ChildrenAsTriggers =false(此種組合衝突)

       UpdateMode =Always    ChildrenAsTriggers =true (此種有效)

       UpdateMode =Conditional  ChildrenAsTriggers =true (此種有效)

       UpdateMode =Conditional  ChildrenAsTriggers =false(此種有效)

   不同的組合方式,不同的位置,顯示出不同情況的重新整理與跳轉,如下一段代碼(此處只顯示一種組合一種位置的情況):

            <form id="form1" runat="server">
     <div id='time'><%=System .DateTime .Now.ToString () %>

      <asp:ScriptManager ID="ScriptManager1"  runat="server"></asp:ScriptManager>
    </div>
         <asp:UpdatePanel ID="UpdatePanel1" runat="server"  RenderMode =Block  UpdateMode =Always ChildrenAsTriggers =true     >
            <ContentTemplate>

                <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                    ConnectionString="Data Source=.;Initial Catalog=B2B;User ID=sa;Password=sa"
                    ProviderName="System.Data.SqlClient"
                    SelectCommand="SELECT [ProductId], [ProductName], [ProductType], [ProductPrice], [ProductQuantity], [ProductAddress] FROM [Products]">
                </asp:SqlDataSource>

                <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
            AutoGenerateColumns="False" DataKeyNames="ProductId"
            DataSourceID="SqlDataSource1" PageSize="15"  EnableViewState="False">
                    <Columns>
                        <asp:BoundField DataField="ProductId" HeaderText="ProductId"
                    InsertVisible="False" ReadOnly="True" SortExpression="ProductId" />
                        <asp:BoundField DataField="ProductName" HeaderText="ProductName"
                    SortExpression="ProductName" />
                        <asp:BoundField DataField="ProductType" HeaderText="ProductType"
                    SortExpression="ProductType" />
                        <asp:BoundField DataField="ProductPrice" HeaderText="ProductPrice"
                    SortExpression="ProductPrice" />
                        <asp:BoundField DataField="ProductQuantity" HeaderText="ProductQuantity"
                    SortExpression="ProductQuantity" />
                        <asp:BoundField DataField="ProductAddress" HeaderText="ProductAddress"
                    SortExpression="ProductAddress" />
                    </Columns>
                </asp:GridView>

                <asp:Button ID="Button1" runat="server" Text="Button"
    onclick="Button1_Click" />
   
            </ContentTemplate>
           
        </asp:UpdatePanel>
     
 <div  id="demo"> </div>
    </form>

  當updatemode=Always 時,

                當botton按鈕與GridView控制項同在一個updatepanel中時,id為time的div時間不重新整理,而gridview實現頁面的跳轉;

                當botton按鈕與GridView控制項在兩個updatepanel中時,id為time的div時間不重新整理,而gridview實現頁面的跳轉;

                當botton在id為demo的div中,gridview在updatepanel中時,id為time的div時間重新整理,gridview實現頁面的跳轉;

 當updatemode=Conditional時,

                當botton按鈕與GridView控制項同在一個updatepanel中時,id為time的div時間不重新整理,而gridview實現頁面的跳轉;

                當botton按鈕與GridView控制項在兩個updatepanel中時,id為time的div時間不重新整理,gridview也不實現頁面的跳轉;

                當botton在id為demo的div中,gridview在updatepanel中時,id為time的div時間重新整理,gridview實現頁面的跳轉;

 

               

聯繫我們

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