⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modifyinfocontrol.ascx.cs

📁 ASP.NET 2.0动态网站设计实例源代码,本书介绍了ASP.NET2.0的基础知识
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ModifyInfoControl : System.Web.UI.UserControl
{
 protected void Page_Load(object sender, EventArgs e)
 {
  if (!IsPostBack)
  {
   if (Session["User"] == null)
   {
    Common.RegisterAlertScript("您还没有登录!", "Login.aspx?fromurl=" + Server.HtmlEncode(Request.Url.ToString()),
     "NotLogin", this.Page);
   }
   else
   {
    UserEntity user = (UserEntity)Session["User"];
    if (user.Address != null)
     tbxAddress.Text = user.Address;
    tbxAnswer.Text = user.Answer;
    tbxQuestion.Text = user.Question;
    tbxTrueName.Text = user.TrueName;
    if (!user.ShowEmail)
     rblstShowEmail.SelectedValue = "0";
    tbxEmail.Text = user.Email;
   }
  }
 }
 protected void btnCancle_Click(object sender, EventArgs e)
 {
  Response.Redirect("default.aspx",true);
 }
 protected void btnModify_Click(object sender, EventArgs e)
 {
  UserEntity user = (UserEntity)Session["User"];
  user.Address = tbxAddress.Text;
  user.Answer = tbxAnswer.Text;
  user.Question = tbxQuestion.Text;
  user.TrueName = tbxTrueName.Text;
  if (rblstShowEmail.SelectedValue == "0")
   user.ShowEmail = false;
  else
   user.ShowEmail = true;
  user.Email = tbxEmail.Text;

  UserBussiness userBuss = new UserBussiness();
  userBuss.ModifyInfo(user);

  if (tbxPassword.Text != "")
  {
   user.Password = tbxPassword.Text;
   userBuss.ModifyPassword(user);
   Session.Clear();
   Common.RegisterAlertScript("修改资料成功!请使用新密码重新登录!", "Login.aspx", "ModfiyPassword", this.Page);
  }
  else
  {
   Common.RegisterAlertScript("修改资料成功!", "Default.aspx", "ModfiyInfo", this.Page);
  }
 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -