protected void Page_Load(object sender, EventArgs e) { ContactID = Int32.Parse((String)Session["Argument"] ?? "-1"); // Should Not, Cannot Continue - Lost Session or User Jumped a Step! if (ContactID < 0) { Response.Redirect("~/Default.aspx"); } btnDelete.Visible = false; lnkEdit.Visible = false; if (((String)Session["Command"]).ToLower().Equals("delete")) { subtitle.InnerHtml = "Are you sure you want to delete this?"; btnDelete.Visible = true; } else { lnkEdit.Visible = true; } if (ContactID > -1) { // Look Up Contact Contact contact = Contact.getByID(ContactID); rofcName.ValueText = contact.Name; rofcAddress.ValueText = contact.Address; rofcCity.ValueText = contact.City; rofcState.ValueText = contact.State; rofcZip.ValueText = contact.Zip; rofcEmail.ValueText = contact.Email; rofcTwitter.ValueText = contact.Twitter; } }
/// <summary> /// Delete Contact Record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { Contact contact = Contact.getByID(ContactID); contact.Delete(); // Assume Deleted - Should Really Check for return Response.Redirect("~/Default.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (((String)Session["Command"] ?? "CREATE").Equals("CREATE")) { btnSave.Text = "Create"; } ContactID = Int32.Parse((String)Session["Argument"] ?? "-1"); if (ContactID > -1) { // Look Up Contact Contact contact = Contact.getByID(ContactID); SaveContact = contact; txtName.ValueText = contact.Name; txtAddress.Text = contact.Address; txtCity.Text = contact.City; txtState.Text = contact.State; txtZip.Text = contact.Zip; txtEmail.Text = contact.Email; txtTwitter.Text = contact.Twitter; ctlPhoneNumbers1.ContactID = contact.ContactID; } else { // Treat as New txtName.ValueText = ""; txtAddress.Text = ""; txtCity.Text = ""; txtState.Text = ""; txtEmail.Text = ""; txtTwitter.Text = ""; } } else { ctlPhoneNumbers1.ContactID = SaveContact.ContactID; } }