Skip to main content
 首页 » 编程设计

c#之为什么我的更新面板不起作用

2024年02月13日14小虾米

我有一个更新面板,其中包含一个复选框和一个面板,复选框的自动回发属性为真,我想在选中复选框时使面板可见,但是当我单击复选框时页面被刷新:(

代码:

<asp:UpdatePanel runat="server" ID="updDate"> 
     <ContentTemplate> 
         <tr> 
             <td> 
                 <br/> 
                  Website Status 
                 <br/> 
             </td> 
             <td> 
             <br/> 
                 <asp:CheckBox runat="server" ID="chkUnderConstruction" Text="  Is Website Active?"  
                 AutoPostBack="True"></asp:CheckBox> 
                 <br/> 
            </td> 
         </tr> 
            <asp:Panel runat="server" ID="pnlDate"> 
                <tr> 
                    <td>Activation Date</td> 
                     <td> 
                        Day: <asp:TextBox runat="server" ID="txtDate" Width="30"> 
                              </asp:TextBox> 
                        Month: <asp:TextBox runat="server" ID="TextBox1" Width="30"> 
                               </asp:TextBox> 
                        Year : <asp:TextBox runat="server" ID="TextBox2" Width="30"> 
                               </asp:TextBox> 
                     </td> 
                 </tr> 
            </asp:Panel> 
         </ContentTemplate> 
     </asp:UpdatePanel> 

页面加载代码:

pnlDate.Visible = chkUnderConstruction.Checked; 

请您参考如下方法:

尝试添加触发器来更新面板

<Triggers> 
<asp:AsyncPostBackTrigger />