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 Admin_EditContactFormField : WebBlocks.AdministrativePage { private int ContactFormFieldID { get { return (ViewState["ContactFormFieldID"] == null ? 0 : (int)ViewState["ContactFormFieldID"]); } set { ViewState["ContactFormFieldID"] = value; } } private int ContactFormID { get { return (ViewState["ContactFormID"] == null ? 0 : (int)ViewState["ContactFormID"]); } set { ViewState["ContactFormID"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request["ContactFormFieldID"] != null) ContactFormFieldID = Int32.Parse(Request["ContactFormFieldID"]); if (Request["ContactFormID"] != null) ContactFormID = Int32.Parse(Request["ContactFormID"]); if (ContactFormFieldID > 0) BindData(); } } private void BindData() { DataRow dr = Database.ContactFormFields_Get(ContactFormFieldID); if (dr != null) { ContactFormID = (int)dr["ContactFormID"]; ddlFieldType.SelectedValue = dr["FieldType"].ToString(); txtLabel.Text = (string)dr["Label"]; txtOptions.Text = (string)dr["Options"]; txtValidation.Text = (string)dr["Validation"]; chkRequired.Checked = (bool)dr["Required"]; } } protected override void OnPreRender(EventArgs e) { if (ddlFieldType.SelectedValue == "7") { txtOptions.Enabled = false; txtValidation.Enabled = false; chkRequired.Enabled = false; reqLabel.Enabled = false; reqLabel.Visible = false; } else { txtOptions.Enabled = true; txtValidation.Enabled = true; chkRequired.Enabled = true; reqLabel.Enabled = true; reqLabel.Visible = true; } base.OnPreRender(e); } protected void btnCancel_Click(object sender, EventArgs e) { Response.Redirect("EditContactForm.aspx?ContactFormID=" + ContactFormID); } protected void btnSave_Click(object sender, EventArgs e) { if (ContactFormFieldID == 0) Database.ContactFormFields_Add(ContactFormID, Int32.Parse(ddlFieldType.SelectedValue), txtLabel.Text, txtOptions.Text, txtValidation.Text, chkRequired.Checked); else Database.ContactFormFields_Update(ContactFormFieldID, ContactFormID, Int32.Parse(ddlFieldType.SelectedValue), txtLabel.Text, txtOptions.Text, txtValidation.Text, chkRequired.Checked); Response.Redirect("EditContactForm.aspx?ContactFormID=" + ContactFormID); } }