Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is the main function for hiding panel

private void LoadPaymentPanels()
        {
            if (ddl_BuyCredits_PaymentMethodTypes.SelectedIndex == 0)
            {
                Bank_Mobile.Visible = true;
                Mobile_Payment.Visible = false;
                CreditCardPanel.Visible = false;
            }
            else if (ddl_BuyCredits_PaymentMethodTypes.SelectedIndex == 1)
            {
                Bank_Mobile.Visible = false;
                Mobile_Payment.Visible = true;
                CreditCardPanel.Visible = false;
            }
            else if (ddl_BuyCredits_PaymentMethodTypes.SelectedIndex == 2)
            {
                Bank_Mobile.Visible = false;
                Mobile_Payment.Visible = false;
                CreditCardPanel.Visible = true;
            }
        }


What I have tried:

But i need one function to show one panel at one time and remaining will automatically hide or manually hide with function ... please help me out..
Posted
Updated 31-May-18 8:05am

private void LoadPaymentPanels()
{
    Panel[] panels = new Panel[] { Bank_Mobile, Mobile_Payment, CreditCardPanel };

    foreach(var panel in panels)
    {
        panel.Visible = false;
    }

    panels[ddl_BuyCredits_PaymentMethodTypes.SelectedIndex].Visible = true;
}
 
Share this answer
 
Sounds like you're looking for the MultiView control[^].
<asp:MultiView id="Payment_Panels" runat="server">
<asp:View id="Bank_Mobile" runat="server">
    ...
</asp:View>
<asp:View id="Mobile_Payment" runat="server">
    ...
</asp:View>
<asp:View id="CreditCardPanel" runat="server">
    ...
</asp:View>
</asp:MultiView>
C#
private void LoadPaymentPanels()
{
    Payment_Panels.ActiveViewIndex = ddl_BuyCredits_PaymentMethodTypes.SelectedIndex;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900