Вопрос

Is this possible? I've got an AJAX TabContainer, and 3 tabs in the container. On Tab #2, I've got a checkbox that, when checked, enables a textbox. When the checkbox is unchecked, the textbox should be disabled.

I've got this code in my ASP form:

    <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>

And I've got this in my code-behind:

    protected void chkRevVal_CheckedChanged(object sender, EventArgs e)
    {
        if (chkRevVal.Checked == true)
        {

            this.txtValComm.Enabled = true;
            this.txtValComm.Focus();

        }
    }

The problem is, when I check the box, the TabContainer goes back to tab #1 every time. Is there a way to keep it on tab #2 after I've checked the checkbox?

Это было полезно?

Решение

Just put the Panel1 control into UpdatePanel with UpdateMode="Conditional". By the way, rewrite chkRevVal_CheckedChanged as this:

this.txtValComm.Enabled = chkRevVal.Checked;
if (txtValComm.Enabled) 
    txtValComm.Focus();
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top