Link to home
Start Free TrialLog in
Avatar of Janu526
Janu526

asked on

How to handle display of a button from a user control in another user control's Update Panel?

I'm using VB.NET for my application. I have an update panel in an user control which uses another 2 user controls
   <asp:UpdatePanel ID="UpdatePanelID" runat="server">
            <ContentTemplate>
                <uc1:UserfirstControl ID="UserfirstControl1" runat="server" />
                <br />
                <uc2:UserSecondControl ID="UserSecondControl2"
                    runat="server" />
            </ContentTemplate>
        </asp:UpdatePanel>

My UserfirstControl has 2 buttons (button1 & button2) and I'm looking to hide one button (button2) in the code behind file(UpdatePanel's Usercontrol Code Behind) based on some condition. Can I able to hide/invisible that button?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Mrunal
Mrunal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes. It is possible. You should wrap your usercontrol with Panel to do so.

<asp:UpdatePanel runat="server" ID="UpdatePanelID" ChildrenAsTriggers="true" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Panel runat="server" ID="pan1" Visible="false"> 
             <uc1:UserfirstControl ID="UserfirstControl1" runat="server" />
        </asp:Panel>

        <asp:Panel runat="server" ID="pan2" Visible="false">
         <uc2:UserSecondControl ID="UserSecondControl2" runat="server" />
        </asp:Panel>

       
    </ContentTemplate>
</asp:UpdatePanel>

Open in new window


In code behind just use below code based on your condition:

 pan2.Visible = false;

Open in new window


HTH.