protected override void OnLoad(EventArgs e) { base.OnLoad(e); string Template = ModuleContext.Settings["template"] as string; if (!Page.IsPostBack) { InitForm(Template); } else { if (Request.QueryString["result"] == "submit") { /* * int id = int.Parse(Request.QueryString["result"]); * OpenFormController ctrl =new OpenFormController(); * var content = ctrl.GetContent(id, ModuleId); */ string json = hfOpenForm.Value; phForm.Visible = false; phResult.Visible = true; string formData = ""; dynamic data = OpenFormUtils.GenerateFormData(json, out formData); string jsonSettings = Settings["data"] as string; SettingsDTO settings = JsonConvert.DeserializeObject <SettingsDTO>(jsonSettings); if (settings != null && settings.Settings != null) { HandlebarsEngine hbs = new HandlebarsEngine(); lMessage.Text = hbs.Execute(settings.Settings.Message, data); lTracking.Text = settings.Settings.Tracking; } } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { hlTemplateExchange.NavigateUrl = EditUrl("ShareTemplate"); var scriptFileSetting = Settings["template"] as string; scriptList.Items.AddRange(OpenFormUtils.GetTemplatesFiles(PortalSettings, ModuleId, scriptFileSetting).ToArray()); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string Template = ModuleContext.Settings["template"] as string; if (!Page.IsPostBack) { InitForm(Template); } else { if (Request.QueryString["result"] == "submit") { /* * int id = int.Parse(Request.QueryString["result"]); * OpenFormController ctrl =new OpenFormController(); * var content = ctrl.GetContent(id, ModuleId); */ string json = Request["__OPENFORM" + ModuleId]; phForm.Visible = false; phResult.Visible = true; string formData = ""; dynamic data = OpenFormUtils.GenerateFormData(json, out formData); string jsonSettings = Settings["data"] as string; SettingsDTO settings = JsonConvert.DeserializeObject <SettingsDTO>(jsonSettings); if (settings != null && settings.Settings != null) { if (!string.IsNullOrEmpty(settings.Settings.Message)) { HandlebarsEngine hbs = new HandlebarsEngine(); lMessage.Text = hbs.Execute(settings.Settings.Message, data); } lTracking.Text = settings.Settings.Tracking; } var razorscript = new FileUri(Path.GetDirectoryName(Template), "aftersubmit.cshtml"); if (razorscript.FileExists) { data.FeedBackMessage = lMessage.Text; data.IPAddress = Request.UserHostAddress; lMessage.Text = ExecuteRazor(razorscript, data); } } } }
private void InitForm(string template) { bool templateDefined = !string.IsNullOrEmpty(template); string settings = ModuleContext.Settings["data"] as string; bool settingsDefined = !string.IsNullOrEmpty(settings); if (!templateDefined || !settingsDefined) { pHelp.Visible = true; } if (ModuleContext.PortalSettings.UserInfo.IsSuperUser) { hlTempleteExchange.NavigateUrl = ModuleContext.EditUrl("ShareTemplate"); hlTempleteExchange.Visible = true; } if (pHelp.Visible && ModuleContext.EditMode) { hlEditSettings.NavigateUrl = ModuleContext.EditUrl("EditSettings"); hlEditSettings.Visible = true; scriptList.Items.AddRange(OpenFormUtils.GetTemplatesFiles(PortalSettings, ModuleId, template).ToArray()); scriptList.Visible = true; } if (string.IsNullOrEmpty(template)) { ScopeWrapper.Visible = false; } if (templateDefined) { IncludeResourses(template); } if (settingsDefined) { SettingsDTO set = JsonConvert.DeserializeObject <SettingsDTO>(settings); if (!string.IsNullOrEmpty(set.Settings.SiteKey)) { ClientResourceManager.RegisterScript(Page, "https://www.google.com/recaptcha/api.js", FileOrder.Js.DefaultPriority, "DnnPageHeaderProvider"); lReCaptcha.Text = "<div class=\"g-recaptcha\" data-sitekey=\"" + set.Settings.SiteKey + "\"></div>"; } } }