zoukankan      html  css  js  c++  java
  • ScriptManager和UpdatePanel控件

    在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实现页面的跳转;

                   

  • 相关阅读:
    HDU6168 Numbers
    HDU6170 Two strings
    UVA11426 GCD
    hihocoder1560 H国的身份证号码II
    HDU6156 Palindrome Function
    UVA10917 Walk Through the Forest
    UVA11374 Airport Express
    hihocoder1323 回文字符串
    hihocoder1543 SCI表示法
    CodeForces501C Misha and Forest
  • 原文地址:https://www.cnblogs.com/paper/p/1533048.html
Copyright © 2011-2022 走看看