控制的可见性状态发生变化

时间:2011-04-24 22:03:45

标签: asp.net c#-4.0 usability

我在实验室项目中完成了一个阶段。我最好用照片随意地描述我的问题。我目前已阅读controls visibility in C#主题,但我需要提出更多问题。我需要知道如何仅使用C#来实现这种困境。

  1. 我有在Page_Load中可见的控件。
  2. enter image description here

    1. 我在下拉列表中选择了一些学生姓名。标签的价值正在发生变化。
    2. enter image description here

      使用的代码:

      protected void ddlStudents_SelectedIndexChanged(object sender, EventArgs e)
      {
          lblEmail.Visible = true;
          lblName.Visible = true;
          lblReg.Visible = true;
          lblUserActive.Visible = true;
          lblTelephone.Visible = true;
          lblFamilyName.Visible = true;
          lblBirth.Visible = true;
      
      
          CatalogAccess ca=new CatalogAccess();
          UserDetails ud = ca.GetUser(23);
          //HiddenID.Value = String.Format(ud.UserID);
      
          lblName.Text = ud.UserName;
          lblEmail.Text = ud.UserEmail;
          lblFamilyName.Text = ud.UserFamilyName;
          lblBirth.Text=String.Format("{0:dd/MM/yyy}",ud.UserBirthDay);
          lblTelephone.Text = ud.UserTelephone;
          lblReg.Text =String.Format("{0:dd/MM/yyy  HH:MM}",ud.RegDate);
          if (ud.UserActive == true)
          {
              chbActive.Checked = true;
              lblUserActive.Text = "Yes";
          }
          else
          {
              chbActive.Checked = false;
              lblUserActive.Text = "No";
          }
          //ud.UserActive != 0 ? chbActive.Checked = false : chbActive.Checked = true;
          //lblUserActive.Text = ud.UserActive != 0 ? "Activated" : "Not Activated";
          //ddlStudents.Items.Clear();
          //PopulateStudentsDDL();
      
      }
      
      1. 更新 enter image description here

        protected void btnUpdate_Click(object sender,EventArgs e) {     lblBirth.Visible = true;     lblReg.Visible = true;     ddlPrefix.Visible = true;     btnUpdateUnderPanel.Visible = true;

        lblName.Visible = false;
        tbName.Visible = true;
        tbName.Text = lblName.Text;
        
        lblFamilyName.Visible = false;
        tbFamilyName.Visible = true;
        tbFamilyName.Text = lblFamilyName.Text;
        
        lblTelephone.Visible = false;
        tbTelephone.Visible = true;
        tbTelephone.Text = lblTelephone.Text;
        
        lblEmail.Visible = false;
        tbEmail.Visible = true;
        tbEmail.Text = lblEmail.Text;
        
        lblUserActive.Visible = false;
        chbActive.Visible = true;
        

        }

      2. 问题是:

        如何以更专业的方式实施?

        请告诉我,不要告诉我关于小组的事。这里不需要面板。我只改变了几个控件。

0 个答案:

没有答案