/// <summary> /// Updates the controls /// </summary> private void UpdateControls() { pnlTemplateLogo.Visible = CommunicationTemplateHelper.HasTemplateLogo(ceEmailTemplate.Text); imgTemplateLogo.Help = CommunicationTemplateHelper.GetTemplateLogoHelpText(ceEmailTemplate.Text); var lavaFieldsTemplateDictionaryFromControls = hfLavaFieldsState.Value.FromJsonOrNull <Dictionary <string, string> >() ?? new Dictionary <string, string>(); lavaFieldsTemplateDictionaryFromControls = CommunicationTemplateHelper.UpdateLavaFieldsTemplateDictionaryFromControls(phLavaFieldsControls, lavaFieldsTemplateDictionaryFromControls); // dictionary of keys and default values from Lava Fields KeyValueList control var lavaFieldsDefaultDictionary = kvlMergeFields.Value.AsDictionary(); ceEmailTemplate.Text = CommunicationTemplateHelper.GetUpdatedTemplateHtml(ceEmailTemplate.Text, imgTemplateLogo.BinaryFileId, lavaFieldsTemplateDictionaryFromControls, lavaFieldsDefaultDictionary); var lavaFieldsTemplateDictionary = CommunicationTemplateHelper.GetLavaFieldsTemplateDictionaryFromTemplateHtml(ceEmailTemplate.Text); hfLavaFieldsState.Value = lavaFieldsTemplateDictionary.ToJson(indentOutput: false); btnUpdateTemplatePreview.Visible = lavaFieldsTemplateDictionary.Any(); CommunicationTemplateHelper.CreateDynamicLavaValueControls(lavaFieldsTemplateDictionary, lavaFieldsDefaultDictionary, phLavaFieldsControls); var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(RockPage); string resolvedPreviewHtml = ceEmailTemplate.Text.ResolveMergeFields(mergeFields); if (cbCssInliningEnabled.Checked) { resolvedPreviewHtml = resolvedPreviewHtml.ConvertHtmlStylesToInlineAttributes(); } ifEmailPreview.Attributes["srcdoc"] = resolvedPreviewHtml; pnlEmailPreview.Visible = true; upnlEmailPreview.Update(); }