我希望在ASP.NET C中隐藏多个面板# [英] I want multiple panels to hide in ASP.NET C#

查看:74
本文介绍了我希望在ASP.NET C中隐藏多个面板#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是隐藏面板的主要功能



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

推荐答案

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


听起来像是在寻找 MultiView 控件 [ ^ ]。

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>

private void LoadPaymentPanels()
{
    Payment_Panels.ActiveViewIndex = ddl_BuyCredits_PaymentMethodTypes.SelectedIndex;
}


这篇关于我希望在ASP.NET C中隐藏多个面板#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆