我有一个配置文件,允许用户显示、编辑、保存。
保存和编辑工作正常。
但是,显示器无法正常工作。
我尝试将标签更改为文字,但它们也没有。
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 SetElementsForEditing() {
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;
}