public static void AJAX_SaveOptionOrder(string delimControlOption_IDs) { FormGeneratorData data = new FormGeneratorData(); data.SetControlOptionOrder(delimControlOption_IDs, "|"); if (HttpContext.Current.Session["ID"] != null) LogMessage("Saved Field Option Order."); }
protected void Page_Load(object sender, EventArgs e) { FormGeneratorData d = new FormGeneratorData(); MasterPage mp = Page.Master; DataTable dtControls = d.GetPageControlsByPageID("1"); foreach (DataRow dr in dtControls.Rows) { string phID = dr["ASP_ID"].ToString(); string type = dr["TypeName"].ToString(); PlaceHolder ph = (PlaceHolder)mp.FindControl(phID); if (type == "TextBox") { TextBox tb = new TextBox(); tb.ID = dr["Unique_ID"].ToString(); tb.CssClass = dr["CssClass"].ToString(); tb.Attributes.Add("placeholder", dr["Placeholder"].ToString()); ph.Controls.Add(tb); } if (type == "ListBox") { ListBox lb = new ListBox(); lb.ID = dr["Unique_ID"].ToString(); lb.CssClass = dr["CssClass"].ToString(); ph.Controls.Add(lb); } else if (type == "DropDownList") { DropDownList ddl = new DropDownList(); ddl.ID = dr["Unique_ID"].ToString(); ddl.CssClass = dr["CssClass"].ToString(); ph.Controls.Add(ddl); } else if (type == "Multi-line") { TextBox tb = new TextBox(); tb.ID = dr["Unique_ID"].ToString(); tb.CssClass = dr["CssClass"].ToString(); tb.TextMode = TextBoxMode.MultiLine; tb.Attributes.Add("placeholder", dr["Placeholder"].ToString()); ph.Controls.Add(tb); } ph.Controls.Add(new LiteralControl("<br />")); } }
protected void btnAddPage_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); if (txtPageName.Text != "" && txtItemID.Text != "") { int newPageID = data.AddPage("1" //only using single column template for now , txtPageName.Text , txtItemID.Text); LoadDropdown(ddlPages, data.GetPages(), "Name", "Page_ID", "Select Form"); if (newPageID != 0) { pnlSetPageFields.Visible = true; ddlPages.SelectedValue = newPageID.ToString(); LogMessage("Added Form."); } else LogMessage("Add Form Fail."); //Load info box and display lblSCID.Text = txtItemID.Text; lblName.Text = txtPageName.Text; lblPath.Text = "Coming Soon!"; pnlPageInfoDisplay.Visible = true; pnlSetPageFields.Visible = true; hidItemID.Value = txtItemID.Text; loadFrame(); //------------------- ReloadControlList(); LoadDropdown(ddlControlList, data.GetAvalableControlsByPage_ID(ddlPages.SelectedValue), "name", "controllist_id", "Select Field"); pnlControlList.Visible = true; //btnNewControl.Visible = true; //------------------- pnlChoosePage.Visible = false; //Clear fields txtPageName.Text = ""; txtItemID.Text = ""; pnlCreatePage.Visible = false; pnlRightSide.Visible = true; } }
protected void btnAddAction_Click(object sender, EventArgs e) { if (ddlActions.SelectedIndex > 0) { string pageControlID = hfPageControlID_Action_ForEdit.Value; FormGeneratorData data = new FormGeneratorData(); data.AddControlAction(pageControlID, ddlActions.SelectedValue); rptrActions.DataSource = data.GetControlActionsByPageControl_ID(pageControlID); rptrActions.DataBind(); if (ddlPages.SelectedIndex != 0) { if (data.DoesPagehaveECASControlAction(ddlPages.SelectedValue)) pnlReturnURL.Visible = true; } } }
protected void chkRequired_CheckChanged(object source, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); CheckBox cb = (CheckBox)source; string pageControl_ID = cb.Attributes["PCID"].ToString(); data.UpdateRequiredByPageControl_ID(pageControl_ID, cb.Checked); }
protected void submit_Click(Object sender, EventArgs e) { Response.Write("yeah!"); //**************************** FormGeneratorData data = new FormGeneratorData(); string pageControlID = ((CrossBrowser_Button)sender).txtCrossBrowserSubmit.Attributes["pageControlID"]; DataTable dtActions = data.GetControlActionsByPageControl_ID(pageControlID); foreach (DataRow action in dtActions.Rows) { string actionName = action["Name"].ToString(); string controlAction_ID = action["ControlAction_ID"].ToString(); if (actionName == "Send Data To Aprimo (test)") { SendDataToAprimo(true); } else if (actionName == "Send Data To Aprimo (live)") { SendDataToAprimo(false); } } PlaceHolder ph = (PlaceHolder)Page.Master.FindControl("phColumn1"); CrossBrowser_Button cbb = (CrossBrowser_Button)ph.FindControl("cbbSubmit"); cbb.lblSuccessMessage.Visible = true; ClearFields(); }
protected void Page_PreInit(object sender, EventArgs e) { FormGeneratorData d = new FormGeneratorData(); itemID = "{4C8C460D-40FD-45EA-A76E-B1AD7953371D}"; //if (!String.IsNullOrEmpty(Request.QueryString["ID"])) //{ // itemID = Request.QueryString["ID"].ToString(); //} DataTable dtPage = d.GetPageBySitecoreItemID(itemID); pageID = dtPage.Rows[0]["Page_ID"].ToString(); this.MasterPageFile = dtPage.Rows[0]["TemplatePath"].ToString(); }
private static void LogMessage(string Message) { FormGeneratorData data = new FormGeneratorData(); if (HttpContext.Current.Session["ID"] != null) { string admin_ID = HttpContext.Current.Session["ID"].ToString(); data.LogAction(admin_ID, Message); } }
protected void rptrOptions_ItemCommand(object source, RepeaterCommandEventArgs e) { string controlOption_ID = e.CommandArgument.ToString(); FormGeneratorData data = new FormGeneratorData(); if (e.CommandName.ToString() == "delete") { data.RemoveControlOption(controlOption_ID); DataTable dtOptions = data.GetControlOptionsByPageControl_ID(hfPageControlID_DD_ForEdit.Value); rptrOptions.DataSource = dtOptions; rptrOptions.DataBind(); } else if (e.CommandName.ToString() == "edit") { hfControlOptionID_ForEdit.Value = e.CommandArgument.ToString(); DataTable dt = data.GetControlOptionsByControlOption_ID(controlOption_ID); txtText.Text = dt.Rows[0]["Text"].ToString(); txtValue.Text = dt.Rows[0]["Value"].ToString(); //load default btnSaveOption.Text = "Save"; } }
protected void ddlPages_SelectedIndexChanged(object sender, EventArgs e) { if (ddlPages.SelectedIndex != 0) { FormGeneratorData data = new FormGeneratorData(); DataTable dtTemplate = data.GetTemplateByPageID(ddlPages.SelectedValue); DataTable dtPages = data.GetPageByPageID(ddlPages.SelectedValue); hidItemID.Value = dtPages.Rows[0]["ItemID"].ToString(); LoadDropdown(ddlStyles, data.GetStyles(), "Name", "StyleType_ID", "Select Style"); if (ddlPages.SelectedIndex > 0) { loadFrame(); btnRemovePage.Visible = true; btnSaveFormInfo.Visible = true; ddlStyles.SelectedIndex = 0; txtCampaign.Text = ""; txtPage.Text = ""; txtSource.Text = ""; if(dtPages.Rows[0]["StyleType_ID"] != DBNull.Value) ddlStyles.SelectedValue = dtPages.Rows[0]["StyleType_ID"].ToString(); if (dtPages.Rows[0]["Tracking_Campaign"] != DBNull.Value) txtCampaign.Text = dtPages.Rows[0]["Tracking_Campaign"].ToString(); if (dtPages.Rows[0]["Tracking_Page"] != DBNull.Value) txtPage.Text = dtPages.Rows[0]["Tracking_Page"].ToString(); if (dtPages.Rows[0]["Tracking_Source"] != DBNull.Value) txtSource.Text = dtPages.Rows[0]["Tracking_Source"].ToString(); } else { btnRemovePage.Visible = false; btnSaveFormInfo.Visible = false; } ReloadControlList(); LoadDropdown(ddlControlList, data.GetAvalableControlsByPage_ID(ddlPages.SelectedValue), "name", "controllist_id", "Select Field"); pnlControlList.Visible = true; pnlEditActions.Visible = false; pnlAddSubmitButton.Visible = false; pnlAprimoInfo.Visible = true; pnlRightSide.Visible = true; pnlSetPageFields.Visible = true; pnlAddEditDropdown.Visible = false; btnAdd.Visible = true; pnlPageInfo.Visible = true; } else { pnlControlList.Visible = false; pnlEditActions.Visible = false; pnlAddSubmitButton.Visible = false; pnlAprimoInfo.Visible = false; pnlRightSide.Visible = false; pnlSetPageFields.Visible = false; btnRemovePage.Visible = false; pnlAddEditDropdown.Visible = false; } }
protected void btnRemovePage_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); if (ddlPages.SelectedIndex != 0) { data.RemovePageByPage_ID(ddlPages.SelectedValue); LoadDropdown(ddlPages, data.GetPages(), "Name", "Page_ID", "Select Form"); pnlControlList.Visible = false; rptrPageControls.DataSource = null; rptrPageControls.DataBind(); phRightSide.Controls.Clear(); lblNoData.Visible = false; LogMessage("Removed Form."); } }
protected void btnLogIn_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); string encryptedUsername = Crypto.Encrypt(txtUserName.Text); string encryptedPassword = Crypto.Encrypt(txtPassword.Text); string admin_ID = data.Login(encryptedUsername, encryptedPassword); if (admin_ID != "0") { pnlLogin.Visible = false; pnlAdmin.Visible = true; Session["ID"] = admin_ID.ToString(); data.LogAction(admin_ID, "Logged In."); } else { pnlLogin.Visible = true; pnlAdmin.Visible = false; Session["ID"] = ""; data.LogAction(admin_ID, "Login Fail."); } }
protected void btnEditExisting_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); LoadDropdown(ddlPages, data.GetPages(), "Name", "Page_ID", "Select Form"); pnlChoosePage.Visible = true; pnlPageInfoDisplay.Visible = false; lblNoData.Visible = false; pnlSetPageFields.Visible = true; pnlCreatePage.Visible = false; pnlControlList.Visible = false; pnlAddSubmitButton.Visible = false; //cbxECAS.Visible = false; phRightSide.Controls.Clear(); rptrPageControls.DataSource = null; rptrPageControls.DataBind(); }
protected void btnCancelAction_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); if (txtAprimoID.Text != "" && txtAprimoSubject.Text != "" && ddlPages.SelectedIndex != 0) data.UpdateAprimoInfo(ddlPages.SelectedValue, txtAprimoSubject.Text, txtAprimoID.Text); if (ddlPages.SelectedIndex != 0) data.UpdateReturnURLByPage_ID(ddlPages.SelectedValue, tbxReturnURL.Text); LogMessage("Updated Return URL (ECAS Aciton)."); LogMessage("Updated Aprimo Data."); pnlEditActions.Visible = false; pnlAddSubmitButton.Visible = false; pnlControlList.Visible = true; pnlReturnURL.Visible = false; }
protected void btnAdd_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); string controlText = ""; if (pnlAddSubmitButton.Visible) controlText = txtButtonText.Text; else if(pnlAddEditContentBlock.Visible) controlText = txtRTE.Text; if (ddlControlList.SelectedIndex == 0) return; int newPageControl_ID = data.AddControlToPlaceHolder(ddlControlList.SelectedValue , ddlPages.SelectedValue , "1" , hfPageControlID_ForEdit.Value , controlText); LogMessage("Added Field '" + controlText + "'"); if (ddlControlList.SelectedValue == "20") pnlAddEditDropdown.Visible = true; ClearFields(); ReloadControlList(); LoadDropdown(ddlControlList, data.GetAvalableControlsByPage_ID(ddlPages.SelectedValue), "name", "controllist_id", "Select Field"); ddlControlList.SelectedIndex = 0; pnlAddSubmitButton.Visible = false; pnlControlList.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpBrowserCapabilities browser = Request.Browser; FormGeneratorData d = new FormGeneratorData(); MasterPage mp = Page.Master; DataTable dtForm = d.GetPageByPageID(pageID); if (dtForm.Rows.Count > 0) { this.Form.ID = dtForm.Rows[0]["FormName"].ToString(); if (dtForm.Rows[0]["CSSClass"] != DBNull.Value) this.Form.Attributes.Add("class", dtForm.Rows[0]["CSSClass"].ToString()); if (dtForm.Rows[0]["Tracking_Campaign"] != DBNull.Value) { HiddenField hfCampaign = new HiddenField(); hfCampaign.ID = "c"; hfCampaign.Value = dtForm.Rows[0]["Tracking_Campaign"].ToString(); this.Form.Controls.Add(hfCampaign); } if (dtForm.Rows[0]["Tracking_Source"] != DBNull.Value) { HiddenField hfSource = new HiddenField(); hfSource.ID = "s"; hfSource.Value = dtForm.Rows[0]["Tracking_Source"].ToString(); this.Form.Controls.Add(hfSource); } if (dtForm.Rows[0]["Tracking_Page"] != DBNull.Value) { HiddenField hfPage = new HiddenField(); hfPage.ID = "_p"; hfPage.Value = dtForm.Rows[0]["Tracking_Page"].ToString(); this.Form.Controls.Add(hfPage); } } else return; object aprimoID = dtForm.Rows[0]["Aprimo_ID"]; object subjectLine = dtForm.Rows[0]["Subject"]; object isModal = dtForm.Rows[0]["IsModal"]; if (isModal != null) { bool isModalForm = Convert.ToBoolean(isModal); PlaceHolder ph = (PlaceHolder)mp.FindControl("phHidden"); HtmlGenericControl hidden = new HtmlGenericControl(); hidden.TagName = "input"; hidden.ID = "hidIsModal"; hidden.Attributes.Add("type", "hidden"); if (isModalForm) hidden.Attributes.Add("value", "true"); else hidden.Attributes.Add("value", "false"); ph.Controls.Add(hidden); } if (aprimoID != null) this.Form.Attributes.Add("AprimoID", aprimoID.ToString()); if (subjectLine != null) this.Form.Attributes.Add("AprimoSubject", subjectLine.ToString()); DataTable dtControls = d.GetPageControlsByPageID(pageID); foreach (DataRow dr in dtControls.Rows) { string pageControl_ID = dr["pageControl_ID"].ToString(); string phID = dr["ASP_ID"].ToString(); string type = dr["TypeName"].ToString(); PlaceHolder ph = (PlaceHolder)mp.FindControl(phID); DataTable dtProperties = d.GetPageControlPropertyValuesByPageControl_ID(pageControl_ID); string isRequired = dr["IsRequired"].ToString(); if (type == "TextBox") { CrossBrowser_TextBox c = (CrossBrowser_TextBox)LoadControl("Controls/CrossBrowser_TextBox.ascx"); string controlName = dr["Type"].ToString().ToLower(); if (isRequired == "True") c.Watermark = dr["Watermark"].ToString() + " *"; else c.Watermark = dr["Watermark"].ToString(); c.tbxCrossBrowser.ID = dr["AprimoFieldName"].ToString(); c.tbxCrossBrowser.CssClass = dr["CssClass"].ToString(); c.tbxCrossBrowser.Attributes.Add("validate", dr["DoValidate"].ToString()); c.tbxCrossBrowser.Attributes.Add("controlname", dr["Type"].ToString().ToLower()); if (controlName == "company") { c.tbxCrossBrowser.ClientIDMode = ClientIDMode.Static; c.tbxCrossBrowser.ID = "company"; } ph.Controls.Add(c); } else if (type == "ListBox") { DataTable dt = d.GetControlOptionsByPageControl_ID(dr["PageControl_ID"].ToString()); ListBox lb = new ListBox(); lb.ID = dr["AprimoFieldName"].ToString(); lb.CssClass = dr["CssClass"].ToString(); lb.SelectionMode = ListSelectionMode.Multiple; lb.Attributes.Add("validate", dr["DoValidate"].ToString()); lb.Attributes.Add("controlName", dr["Type"].ToString().ToLower()); FormGeneratorTools.BindObject(lb, dt, "Text", "Value", "Select One"); ph.Controls.Add(lb); ph.Controls.Add(new LiteralControl("<br />")); } else if (type == "DropDownList") { DropDownList ddl = new DropDownList(); bool hasConstantValues = Convert.ToBoolean(dr["HasConstantValues"]); DataTable dt; if (hasConstantValues) { dt = d.GetControlConstantValues(dr["ControlList_ID"].ToString()); FormGeneratorTools.BindObject(ddl, dt, "Text", "Value", dr["type"].ToString()); } else { dt = d.GetControlOptionsByPageControl_ID(dr["PageControl_ID"].ToString()); string defaultValue = ""; if (dr["DefaultValue"] != null) defaultValue = dr["DefaultValue"].ToString(); FormGeneratorTools.BindObject(ddl, dt, "Text", "Value", defaultValue); } ddl.ID = dr["AprimoFieldName"].ToString(); ddl.CssClass = dr["CssClass"].ToString(); ddl.Attributes.Add("validate", dr["DoValidate"].ToString()); ddl.Attributes.Add("controlName", dr["Type"].ToString().ToLower()); if (isRequired == "True") ddl.Items[0].Text = ddl.Items[0].Text + " *"; ph.Controls.Add(ddl); ph.Controls.Add(new LiteralControl("<br />")); } else if (type == "Multi-line") { CrossBrowser_TextArea c = (CrossBrowser_TextArea)LoadControl("Controls/CrossBrowser_TextArea.ascx"); c.Watermark = dr["Watermark"].ToString(); c.tbxCrossBrowser.ID = dr["AprimoFieldName"].ToString(); c.tbxCrossBrowser.CssClass = dr["CssClass"].ToString(); c.tbxCrossBrowser.Attributes.Add("validate", dr["DoValidate"].ToString()); c.tbxCrossBrowser.Attributes.Add("controlname", dr["Type"].ToString().ToLower()); if (isRequired == "True") c.Watermark = dr["Watermark"].ToString() + " *"; else c.Watermark = dr["Watermark"].ToString(); ph.Controls.Add(c); //ph.Controls.Add(new LiteralControl("<br />")); } else if (type == "Literal") { Literal lit = new Literal(); lit.ID = dr["AprimoFieldName"].ToString(); SetControlProperties(lit, dtProperties); ph.Controls.Add(lit); ph.Controls.Add(new LiteralControl("<br />")); } else if (type == "Submit") { string errorMessage = "Please fix errors."; string successMessage = "Submitted successfully!"; CrossBrowser_Button c = (CrossBrowser_Button)LoadControl("Controls/CrossBrowser_Button.ascx"); c.ID = "cbbSubmit"; c.ehButtonClicked += new EventHandler(submit_Click); c.txtCrossBrowserSubmit.CssClass = dr["CssClass"].ToString(); c.txtCrossBrowserSubmit.Text = d.GetControlProperty(dr["PageControl_ID"].ToString(), "Text"); c.txtCrossBrowserSubmit.OnClientClick = "return IsValid()"; c.txtCrossBrowserSubmit.ID = dr["AprimoFieldName"].ToString(); c.txtCrossBrowserSubmit.Attributes.Add("pageControlID", dr["PageControl_ID"].ToString()); c.ErrorMessage = errorMessage; c.SuccessMessage = successMessage; //c.lblErrorMessage.Text = errorMessage; c.lblSuccessMessage.Text = successMessage; ph.Controls.Add(c); ph.Controls.Add(new LiteralControl("<br />")); } } HtmlGenericControl dbFormHidden = new HtmlGenericControl("div"); dbFormHidden.ID = "db-form-hidden"; Page.Controls.Add(dbFormHidden); HtmlGenericControl tracking = new HtmlGenericControl("div"); tracking.ID = "trackingFields"; Page.Controls.Add(tracking); HiddenField hf = new HiddenField(); hf.ID = "hfDBResults"; hf.Visible = true; HtmlGenericControl wrapper = new HtmlGenericControl("div"); wrapper.Controls.Add(hf); Page.Form.Controls.Add(wrapper); Page.Controls.Add(new LiteralControl(@" <script type='text/javascript'> $(document).ready(function(){ initAutocomplete(); getResultsIP(); renderHiddenTrackingFields(); if($('.ui-autocomplete-input').attr('name') == '') $('.ui-autocomplete-input').hide(); }) </script> ")); } }
protected void ddlControlList_SelectedIndexChanged(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); if (ddlControlList.SelectedValue != "-1") { btnAdd.Visible = true; } else { pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = false; btnAdd.Visible = false; } if (DoesListContainString(ddlControlList.SelectedValue,"1,4,8,9,10,11,19")) { pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = true; pnlAddEditContentBlock.Visible = false; } else if (ddlControlList.SelectedValue == "12") // Content Block { pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = true; } else if (ddlControlList.SelectedValue == "13") //Submit { DataTable dtActionTypes = data.GetControlActionTypes(); LoadDropdown(ddlActions, dtActionTypes, "Name", "ControlActionType_ID", "Select Action"); btnAdd.Visible = true; pnlEditActions.Visible = false; pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = false; } else if (ddlControlList.SelectedValue == "20") //Custom Dropdown { pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = false; btnAdd.Visible = true; } else if (ddlControlList.SelectedValue == "14") //Image { pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = false; } }
protected void btnSaveFormInfo_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); if (ddlStyles.SelectedIndex != 0 && txtCampaign.Text != "" && txtPage.Text != "" && txtSource.Text != "") { data.UpdatePageInfo(ddlPages.SelectedValue, ddlStyles.SelectedValue, txtCampaign.Text, txtPage.Text, txtSource.Text); LogMessage("Updated page info."); } }
protected void ddlTemplates_SelectedIndexChanged(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); string path = ""; imgTemplatePreview.ImageUrl = path; }
protected void btnSaveOption_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); if (txtText.Text != "" && txtValue.Text != "") { if (hfControlOptionID_ForEdit.Value == "") { data.AddControlOption(hfPageControlID_DD_ForEdit.Value, txtText.Text, txtValue.Text); LogMessage("Added Dropdown Option."); } else { data.UpdateControlOption(hfControlOptionID_ForEdit.Value, txtText.Text, txtValue.Text); hfControlOptionID_ForEdit.Value = ""; LogMessage("Updated Dropdown Option."); } txtText.Text = ""; txtValue.Text = ""; btnSaveOption.Text = "Add"; } if (txtDefaultOption.Text != "") data.SavePageControlDefaultOption(txtDefaultOption.Text, hfPageControlID_DD_ForEdit.Value); DataTable dtOptions = data.GetControlOptionsByPageControl_ID(hfPageControlID_DD_ForEdit.Value); rptrOptions.DataSource = dtOptions; rptrOptions.DataBind(); }
protected void rptrActions_ItemCommand(object source, RepeaterCommandEventArgs e) { HiddenField hf = (HiddenField)e.Item.FindControl("hidPageControl_ID"); string controlActionID = e.CommandArgument.ToString(); FormGeneratorData data = new FormGeneratorData(); data.RemoveControlAction(controlActionID); LogMessage("Removed Action from Submit Button."); DataTable dtActions = data.GetControlActionsByPageControl_ID(hf.Value); rptrActions.DataSource = dtActions; rptrActions.DataBind(); if (ddlPages.SelectedIndex != 0) { if (data.DoesPagehaveECASControlAction(ddlPages.SelectedValue)) pnlReturnURL.Visible = true; else pnlReturnURL.Visible = false; } }
protected void btnUpdateButtonText_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); data.UpdateControlPropertySetting(hfPageControlID_ForEdit.Value, "Text", txtButtonText.Text); pnlAddSubmitButton.Visible = false; pnlEditActions.Visible = false; txtButtonText.Text = ""; pnlControlList.Visible = true; hfPageControlID_ForEdit.Value = ""; hfControlListID_ForEdit.Value = ""; hfPageControlSetting_ID.Value = ""; LogMessage("Updated Button Text"); }
protected void rptrPageControls_ItemCommand(object source, RepeaterCommandEventArgs e) { FormGeneratorData data = new FormGeneratorData(); HiddenField hf = (HiddenField)e.Item.FindControl("hidPageControlID"); DataTable dtProperties = data.GetPageControlPropertyValuesByPageControl_ID(hf.Value); if (dtProperties.Rows.Count > 0) { if (dtProperties.Rows[0]["ControlList_Name"].ToString() == "Content Block") { pnlEditActions.Visible = false; pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = true; pnlAddSubmitButton.Visible = false; btnAdd.Visible = true; txtRTE.Text = dtProperties.Rows[0]["SettingValue"].ToString(); btnRTECancel.Visible = true; btnUpdateRTE.Visible = true; } else if (dtProperties.Rows[0]["ControlList_Name"].ToString() == "Submit") { pnlEditActions.Visible = false; pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = false; pnlAddSubmitButton.Visible = true; btnAdd.Visible = true; txtButtonText.Text = dtProperties.Rows[0]["SettingValue"].ToString(); } hfPageControlSetting_ID.Value = dtProperties.Rows[0]["PageControlSetting_ID"].ToString(); hfControlListID_ForEdit.Value = dtProperties.Rows[0]["ControlList_ID"].ToString(); hfPageControlID_ForEdit.Value = dtProperties.Rows[0]["PageControl_ID"].ToString(); } if (e.CommandName.ToString() == "delete") { data.RemovePageControl(e.CommandArgument.ToString()); LoadDropdown(ddlControlList, data.GetAvalableControlsByPage_ID(ddlPages.SelectedValue), "name", "controllist_id", "Select Field"); pnlControlList.Visible = true; btnAdd.Visible = true; pnlAddEditDropdown.Visible = false; pnlAddEditContentBlock.Visible = false; pnlAddEditTextBox.Visible = false; pnlAddSubmitButton.Visible = false; LogMessage("Deleted Field From Form."); } else // Edit { pnlControlList.Visible = false; DataTable dtControlInfo = data.GetControlInfoByPageControl_ID(hf.Value); string controlType = dtControlInfo.Rows[0]["ControlType"].ToString(); if (controlType == "TextBox" || controlType == "Multi-line") { pnlEditActions.Visible = false; pnlAddEditDropdown.Visible = false; pnlAddEditTextBox.Visible = true; pnlAddEditContentBlock.Visible = false; btnAdd.Visible = true; hfControlListID_ForEdit.Value = dtControlInfo.Rows[0]["ControlList_ID"].ToString(); hfPageControlID_ForEdit.Value = hf.Value; } else if (controlType == "DropDownList") { pnlEditActions.Visible = false; pnlAddEditDropdown.Visible = true; pnlAddEditTextBox.Visible = false; pnlAddEditContentBlock.Visible = false; btnAdd.Visible = false; hfPageControlID_DD_ForEdit.Value = hf.Value; DataTable dtOptions = data.GetControlOptionsByPageControl_ID(hf.Value); string defaultValue = data.GetDefaultOptionByPageControl_ID(hf.Value); txtDefaultOption.Text = defaultValue; rptrOptions.DataSource = dtOptions; rptrOptions.DataBind(); } else if (controlType == "Submit") { pnlEditActions.Visible = true; pnlAddSubmitButton.Visible = true; pnlControlList.Visible = false; btnUpdateButtonText.Visible = true; hfPageControlID_Action_ForEdit.Value = hf.Value; hfPageControlID_ForEdit.Value = hf.Value; DataTable dtActionTypes = data.GetControlActionTypes(); DataTable dtActions = data.GetControlActionsByPageControl_ID(hf.Value); DataTable dtAprimoInfo = data.GetAprimoInfoByPage_ID(ddlPages.SelectedValue); if (dtAprimoInfo != null) { txtAprimoSubject.Text = dtAprimoInfo.Rows[0]["Subject"].ToString(); txtAprimoID.Text = dtAprimoInfo.Rows[0]["Aprimo_ID"].ToString(); } LoadDropdown(ddlActions, dtActionTypes, "Name", "ControlActionType_ID", "Select Action"); rptrActions.DataSource = dtActions; rptrActions.DataBind(); if (ddlPages.SelectedIndex != 0) { if (data.DoesPagehaveECASControlAction(ddlPages.SelectedValue)) { string url = ""; if (ddlPages.SelectedIndex != 0) url = data.GetReturnURLByPage_ID(ddlPages.SelectedValue); tbxReturnURL.Text = url; pnlReturnURL.Visible = true; } } } } ReloadControlList(); }
protected void btnUpdateRTE_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); data.SavePageControlSetting(hfPageControlID_ForEdit.Value, "4", txtRTE.Text); //4 = Content Block pnlAddEditContentBlock.Visible = false; pnlControlList.Visible = true; hfPageControlID_ForEdit.Value = ""; hfControlListID_ForEdit.Value = ""; LogMessage("Updated Content Block"); }
private void ReloadControlList() { FormGeneratorData data = new FormGeneratorData(); DataTable dt = data.GetPageControlsByPlaceholderID("1", ddlPages.SelectedValue); if (dt.Rows.Count > 0) { rptrPageControls.DataSource = dt; rptrPageControls.DataBind(); lblNoData.Visible = false; } else { lblNoData.Visible = true; } }
//protected void btnUpdateAprimoInfo_Click(object sender, EventArgs e) //{ // FormGeneratorData data = new FormGeneratorData(); // if (txtAprimoID.Text != "" && txtAprimoSubject.Text != "" && ddlPages.SelectedIndex != 0) // data.UpdateAprimoInfo(ddlPages.SelectedValue, txtAprimoSubject.Text, txtAprimoID.Text); // LogMessage("Updated Aprimo Data."); //} protected void btnUpdate_Click(object sender, EventArgs e) { FormGeneratorData data = new FormGeneratorData(); if(ddlPages.SelectedIndex != 0) data.UpdateReturnURLByPage_ID(ddlPages.SelectedValue, tbxReturnURL.Text); LogMessage("Updated Return URL (ECAS Aciton)."); }
protected void Page_Load(object sender, EventArgs e) { FormGeneratorData d = new FormGeneratorData(); MasterPage mp = Page.Master; this.Form.ID = d.GetPageByPageID(pageID).Rows[0]["FormName"].ToString(); DataTable dtControls = d.GetPageControlsByPageID(pageID); foreach (DataRow dr in dtControls.Rows) { string pageControl_ID = dr["pageControl_ID"].ToString(); string phID = dr["ASP_ID"].ToString(); string type = dr["TypeName"].ToString(); PlaceHolder ph = (PlaceHolder)mp.FindControl(phID); DataTable dtProperties = d.GetPageControlPropertyValuesByPageControl_ID(pageControl_ID); if (type == "TextBox") { TextBox tb = new TextBox(); tb.ID = dr["AprimoFieldName"].ToString(); tb.CssClass = dr["CssClass"].ToString(); tb.Attributes.Add("placeholder", dr["Watermark"].ToString()); tb.Attributes.Add("validate", dr["DoValidate"].ToString()); tb.Attributes.Add("controlName", dr["Type"].ToString().ToLower()); ph.Controls.Add(tb); } else if (type == "ListBox") { DataTable dt = d.GetControlOptionsByPageControl_ID(dr["PageControl_ID"].ToString()); ListBox lb = new ListBox(); lb.ID = dr["AprimoFieldName"].ToString(); lb.CssClass = dr["CssClass"].ToString(); lb.SelectionMode = ListSelectionMode.Multiple; lb.Attributes.Add("validate", dr["DoValidate"].ToString()); lb.Attributes.Add("controlName", dr["Type"].ToString().ToLower()); FormGeneratorTools.BindObject(lb, dt, "Text", "Value", "Select One"); ph.Controls.Add(lb); } else if (type == "DropDownList") { DataTable dt = d.GetControlOptionsByPageControl_ID(dr["PageControl_ID"].ToString()); DropDownList ddl = new DropDownList(); ddl.ID = dr["AprimoFieldName"].ToString(); ddl.CssClass = dr["CssClass"].ToString(); ddl.Attributes.Add("validate", dr["DoValidate"].ToString()); ddl.Attributes.Add("controlName", dr["Type"].ToString().ToLower()); FormGeneratorTools.BindObject(ddl, dt, "Text", "Value", "Select One"); ph.Controls.Add(ddl); } else if (type == "Multi-line") { TextBox tb = new TextBox(); tb.ID = dr["AprimoFieldName"].ToString(); tb.CssClass = dr["CssClass"].ToString(); tb.TextMode = TextBoxMode.MultiLine; tb.Attributes.Add("placeholder", dr["Watermark"].ToString()); tb.Attributes.Add("controlName", dr["Type"].ToString().ToLower()); tb.Attributes.Add("validate", dr["DoValidate"].ToString()); ph.Controls.Add(tb); } else if (type == "Literal") { Literal lit = new Literal(); lit.ID = dr["AprimoFieldName"].ToString(); SetControlProperties(lit, dtProperties); ph.Controls.Add(lit); } else if (type == "Image") { Image img = new Image(); SetControlProperties(img, dtProperties); ph.Controls.Add(img); } else if (type == "Submit") { Button submit = new Button(); submit.Text = "Submit"; submit.OnClientClick = "return IsValid()"; submit.Click += new EventHandler(submit_Click); submit.ID = dr["AprimoFieldName"].ToString(); ph.Controls.Add(submit); } ph.Controls.Add(new LiteralControl("<br />")); } }
protected void Page_PreInit(object sender, EventArgs e) { FormGeneratorData d = new FormGeneratorData(); string itemID = ""; if (!String.IsNullOrEmpty(Request.QueryString["ID"])) { itemID = Request.QueryString["ID"].ToString(); DataTable dtPage = d.GetPageBySitecoreItemID(itemID); pageID = dtPage.Rows[0]["Page_ID"].ToString(); this.MasterPageFile = dtPage.Rows[0]["TemplatePath"].ToString(); } }