-C#标签&;文字不显示值

本文关键字:显示 文字 标签 amp -C# | 更新日期: 2023-09-27 18:23:46

我有一个配置文件,允许用户显示、编辑和保存。

保存和编辑工作正常。

但是,显示器工作不正常。

我试着把标签改成文字,但他们也没有。

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.BindGenderDropDownList();
            //this.BindTimeZonesDropDownList();
            //this.BindCulturesDropDownList();
            if (!string.IsNullOrEmpty(Membership.GetUser().UserName))
            {
                Profile = MyProfile.GetProfile(Membership.GetUser().UserName);
                this.DisplayProfile();
            }
        }

    }
    protected void btnGo_Click(object sender, EventArgs e)
    {
        this.DisplayProfile();
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        this.EditProfile();
    }
    protected void btnCancelDisplay_Click(object sender, EventArgs e)
    {
        this.ResetElements();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        this.SaveProfile();
    }
    protected void btnCancelEdit_Click(object sender, EventArgs e)
    {
        this.ResetElements();
    }
    private void DisplayProfile()
    {


            this.SetElementsForDisplaying();
            litfullname.Text = this.Profile.ProfileDetail.FullName;

    }
    private void EditProfile()
    {
        this.SetElementsForEditing();

        if (Profile.ProfileDetail == null)
        {
            txtfname.Text = this.Profile.ProfileDetail.FullName;
            txtcardno.Text = this.Profile.ProfileDetail.IdentityCardNo;
            ddlcardcolor.SelectedValue = this.Profile.ProfileDetail.IdentityCardColour;
            txtcardexp.Text = this.Profile.ProfileDetail.IdentityCardExpiryDate.ToString("dd MMMM yyyy");
            ddlrace.Text = this.Profile.ProfileDetail.Race;
            ddlreligion.SelectedValue = this.Profile.ProfileDetail.Religion;
            txtaddress1.Text = this.Profile.ProfileDetail.ContactInformation.Address1;
            txtaddress2.Text = this.Profile.ProfileDetail.ContactInformation.Address2;
            txtaddress3.Text = this.Profile.ProfileDetail.ContactInformation.Address3;
            txtpostcode.Text = this.Profile.ProfileDetail.ContactInformation.Postcode;
            ddldistrict.SelectedValue = this.Profile.ProfileDetail.ContactInformation.District;
            txtphoneoffice.Text = this.Profile.ProfileDetail.ContactInformation.OfficePhone;
            txtphonehome.Text = this.Profile.ProfileDetail.ContactInformation.HomePhone;
            txtphonecell.Text = this.Profile.ProfileDetail.ContactInformation.MobilePhone;
            txtemail.Text = this.Profile.ProfileDetail.ContactInformation.Email;
        }

    }

保存配置文件。这工作正常。

    private void SaveProfile()
    {
        if (Profile.ProfileDetail == null)
        {
            this.Profile.ProfileDetail.FullName = txtfname.Text;
            this.Profile.ProfileDetail.IdentityCardNo = txtcardno.Text;
            this.Profile.ProfileDetail.IdentityCardColour = ddlcardcolor.SelectedValue;
            this.Profile.ProfileDetail.IdentityCardExpiryDate = DateTime.ParseExact(txtcardexp.Text, "dd MMMM yyyy", null);
            this.Profile.ProfileDetail.Race = ddlrace.SelectedValue;
            this.Profile.ProfileDetail.Religion = ddlreligion.SelectedValue;
            this.Profile.ProfileDetail.ContactInformation.Address1 = txtaddress1.Text;
            this.Profile.ProfileDetail.ContactInformation.Address2 = txtaddress2.Text;
            this.Profile.ProfileDetail.ContactInformation.Address3 = txtaddress3.Text;
            this.Profile.ProfileDetail.ContactInformation.Postcode = txtpostcode.Text;
            this.Profile.ProfileDetail.ContactInformation.District = ddldistrict.SelectedValue;
            this.Profile.ProfileDetail.ContactInformation.OfficePhone = txtphoneoffice.Text;
            this.Profile.ProfileDetail.ContactInformation.HomePhone = txtphonehome.Text;
            this.Profile.ProfileDetail.ContactInformation.MobilePhone = txtphonecell.Text;
            this.Profile.ProfileDetail.ContactInformation.Email = txtemail.Text;
        }

        this.Profile.Save();
       this.ResetElements();
    }

显示,无法正常工作

    private void SetElementsForDisplaying()
    {

        pnlDisplayValues.Visible = true;
        pnlSetValues.Visible = false; 
        litUserTitle.Visible = false;
        litUserTitle.Text = string.Format("Display profile for {0}", this.Profile.UserName);
    }

编辑配置文件。工作正常private void SetElementsForEdit(){

        pnlDisplayValues.Visible = false;
        pnlSetValues.Visible = true;
        litUserTitle.Visible = true;
        litUserTitle.Text = string.Format("Edit profile for {0}", this.Profile.UserName);
    }
    private void ResetElements()
    {
        pnlSetValues.Visible = false;
        pnlDisplayValues.Visible = true;
        litUserTitle.Visible = true;
    }

-C#标签&;文字不显示值

 private void SetElementsForDisplaying()
    {
        pnlDisplayValues.Visible = true;
        pnlSetValues.Visible = false; 
        litUserTitle.Visible = true; // set this as visible 
        litUserTitle.Text = string.Format("Display profile for {0}", this.Profile.UserName);
    }

pnlDisplayValues面板中添加所需的文字,并在DisplayProfile()方法中设置值