当AutoPostBack = true时,防止AJAX TabContainer上的页面重新加载

本文关键字:新加载 加载 true AutoPostBack TabContainer AJAX 防止 | 更新日期: 2023-09-27 18:08:48

这可能吗?我有一个AJAX TabContainer,并在容器3选项卡。在Tab #2上,我有一个复选框,当被选中时,启用文本框。当复选框未选中时,文本框应该被禁用。

我有这个代码在我的ASP形式:

    <AJAXControls:TabContainer runat="server" ID="tabContainer" Height="373" Width="900" > 
        <AJAXControls:TabPanel ID="firstTab" HeaderText="First Tab" runat="server"> 
            <ContentTemplate> 
                <asp:Label ID="Label1" runat="server">You are in the First tab.</asp:Label> 
            </ContentTemplate> 
        </AJAXControls:TabPanel> 
        <AJAXControls:TabPanel ID="secondTab" HeaderText="Second Tab" runat="server"> 
            <ContentTemplate> 
                <div>
                <asp:Panel ID="Panel1" runat="server" Height="70px" style="margin-left: 19px" 
                    Width="860px" BorderStyle="Groove" BorderWidth="2px">
                        <table>
                            <tr>
                                <td width="170">Review Validated:</td>
                                <td width="50"><asp:CheckBox ID="chkRevVal" runat="server" Text=" " oncheckedchanged="chkRevVal_CheckedChanged" AutoPostBack="true" /></td>
                                <td width="40"></td>
                                <td width="170">Validation Comments:</td>
                                <td width="380" rowspan = "4"><asp:textbox id="txtValComm" runat="server" textmode="multiline" rows="4" Width="380px"></asp:textbox></td>
                            </tr>
                            <tr></tr>
                            <tr></tr>
                            <tr></tr>
                        </table>
                </asp:Panel>             
            </ContentTemplate> 
        </AJAXControls:TabPanel> 
    </AJAXControls:TabContainer>

我在我的代码后面有这个:

    protected void chkRevVal_CheckedChanged(object sender, EventArgs e)
    {
        if (chkRevVal.Checked == true)
        {
            this.txtValComm.Enabled = true;
            this.txtValComm.Focus();
        }
    }

问题是,当我选中这个框时,TabContainer每次都会回到tab #1。在我选中复选框后,是否有办法将它保持在标签#2上?

当AutoPostBack = true时,防止AJAX TabContainer上的页面重新加载

Panel1控件与UpdateMode="Conditional"放入UpdatePanel中。顺便说一下,将chkRevVal_CheckedChanged重写为:

this.txtValComm.Enabled = chkRevVal.Checked;
if (txtValComm.Enabled) 
    txtValComm.Focus();