Source

UserControl / UserControl / update.aspx.cs

Full commit
using System;
using System.Web;

namespace UserControl
{
    public partial class update : System.Web.UI.Page
    {
        private static string MainPageUrl = "view.aspx";

        private User _TargetUser;
        private User TargetUser
        {
            get
            {
                if (_TargetUser == null)
                {
                    string userID = HttpUtility.UrlDecode(Request.QueryString["id"]);
                    if (userID != null) _TargetUser = new Users().FindUserByID(userID);
                }
                return _TargetUser;
            }
        }

        private void ShowError(string message)
        {
            LabelError.Text = HttpUtility.HtmlEncode(message);
            LabelError.Visible = true;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (new Login(Session).LoginID == null) Response.Redirect(Login.LoginUrl);

            if (TargetUser == null) Response.Redirect(MainPageUrl);
            if (!IsPostBack)
            {
                LabelUserID.Text = HttpUtility.HtmlEncode(TargetUser.ID);
                TextBoxName.Text = TargetUser.Name;
                TextBoxAge.Text = TargetUser.Age.ToString();
            }
        }

        protected void ButtonUserForm_Click(object sender, EventArgs e)
        {
            uint age;
            if (!uint.TryParse(TextBoxAge.Text, out age)) age = 0;
            try
            {
                TargetUser.Name = TextBoxName.Text;
                TargetUser.Age = age;
                if (!LinkButtonResetPassword.Enabled) TargetUser.ResetPass();
            }
            catch (FormatException err)
            {
                ShowError(err.Message);
                return;
            }
            Session["TargetUser"] = TargetUser;
            Response.Redirect("confirm.aspx");
        }

        protected void LinkButtonResetPassword_Click(object sender, EventArgs e)
        {
            TargetUser.ResetPass();
            LabelPass.Text = TargetUser.Pass;
            LinkButtonResetPassword.Enabled = false;
        }
    }
}