Wednesday, 18 January 2012

How can we access a control outside the update panel with an control inside the update panel


I put the TextBox in another UpdatePanel and then called the Update method:
Here is my new code:



<asp:UpdatePanel runat="server" ID="uplMaster" UpdateMode="Always">
    <ContentTemplate>
        <asp:CheckBox ID="cbShowText" runat="server" Text="Show Some Text" AutoPostBack="true"
            OnCheckedChanged="cbShowText_CheckedChanged" />
    </ContentTemplate>
   </asp:UpdatePanel>
   <asp:UpdatePanel runat="server" ID="uplDetail" UpdateMode="Conditional">
       <ContentTemplate>
           <asp:TextBox ID="txtBox" Text="Empty" runat="server" />
       </ContentTemplate>
   </asp:UpdatePanel>
Code Behind:
protected void cbShowText_CheckedChanged(object sender, EventArgs e)
        {
           txtBox.Text = "Some Text";
           uplDetail.Update();
        }

No comments:

Post a Comment