UpdatePanel的几个属性

UpdatePanel的RenderMode属性
RenderMode Block:使用div包含内容 Inline:使用span包含内容

UpdatePanel的UpdateMode属性
Conditional:表示只用UpdatePanel内的控件有回发的时候UpdatePanel才更新 Always:这是默认值表示页面上所有的控件回发都会引起UpdatePanel更新一般建议设置成Conditional,以减少不必要的数据传输

UpdatePanel属性:UpdateMode和ChildrenAsTriggers的关系
UpdateMode="Always" ChildrenAsTriggers="false" 这样系统将会抛出“An error has occurred! ”的错误当ChildrenAsTriggers设置成“false”的时候,UpdateMode一定要设置成“Conditional”

PostBackTrigger属性,可以指定UpdatePanel1外面的Button2作为满足更新UpdatePanel的条件,但这样点Button2会引起页面刷新

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            
<ContentTemplate>
                
<%= DateTime.Now %>
                
<asp:Button ID="Button1" runat="server" Text="Button" />
            
</ContentTemplate>
            
<Triggers>
                
<asp:PostBackTrigger ControlID="Button2" />
            
</Triggers>
        
</asp:UpdatePanel>
        
        
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
            
<ContentTemplate>
                
<%= DateTime.Now %>
                
<asp:Button ID="Button2" runat="server" Text="Button" />
            
</ContentTemplate>
        
</asp:UpdatePanel>

原文地址:https://www.cnblogs.com/timy/p/1167797.html