如何隐藏控制标题

时间:2014-05-05 01:50:20

标签: c# asp.net

  1. 如何隐藏TextBox标题

    我希望能够在我的网络表单上隐藏文本框标题,我能够隐藏textBoxes但不能隐藏Caption。你能告诉我我错过了什么吗?

                                                                                                                                                                                                

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

    protected void Page_Load(object sender, EventArgs e)
    {
    if (cmdbox_TypePayment.SelectedIndex == 0)
    {
        txt_Carte.Visible = false;
        txt_CarteNum.Visible = false;
        txt_CarteDate.Visible = false;
        txt_CarteCCV.Visible = false;
    }
    }
    protected void cmdbox_TypePayment_SelectedIndexChanged(object sender, EventArgs e)
    {
    if (cmdbox_TypePayment.SelectedIndex == 0)
    {
        txt_Carte.Visible = false;
        txt_CarteNum.Visible = false;
        txt_CarteDate.Visible = false;
        txt_CarteCCV.Visible = false;
    }
    
     else if (cmdbox_TypePayment.SelectedIndex == 1)
    {
        txt_Carte.Visible = true;
        txt_CarteNum.Visible = true;
        txt_CarteDate.Visible = true;
        txt_CarteCCV.Visible = true;
    }
    }
    

1 个答案:

答案 0 :(得分:0)

为标签设置 ID 并将其隐藏在同一个函数中。假设标签有ID lblCaption ..

protected void cmdbox_TypePayment_SelectedIndexChanged(object sender, EventArgs e)
{
    if (cmdbox_TypePayment.SelectedIndex == 0)
    {
       lblCaption.Visible = false;
       txt_Carte.Visible = false;
       txt_CarteNum.Visible = false;
       txt_CarteDate.Visible = false;
       txt_CarteCCV.Visible = false;
    }

    else if (cmdbox_TypePayment.SelectedIndex == 1)
    {
       lblCaption.Visible = true;
       txt_Carte.Visible = true;
       txt_CarteNum.Visible = true;
       txt_CarteDate.Visible = true;
       txt_CarteCCV.Visible = true;
    }
}
相关问题