protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (this.FormData != null) { this.AddCssClass("logicalForm"); this.Attributes.Add("data-siteId", _currentSiteId.ToString()); this.Attributes.Add("data-formId", this.FormId.ToString()); this.Attributes.Add("data-fieldName", this.FormData.Title); this.AddCssClass("analyticForm"); if (!Page.IsPostBack) { foreach (FieldControl fieldControl in this.FieldControls) { string fieldName = Helpers.GetFieldName(fieldControl); if (_isProgressiveForm) { if (_priorFormEntry != null) { if (fieldName == _progressiveKeyFieldName && (_priorFormEntry.DoesFieldExist(fieldName) && _priorFormEntry.GetValue(fieldName) != null)) { fieldControl.Value = _priorFormEntry.GetValue(fieldName); } } } fieldControl.AddCssClass("faContainer"); fieldControl.Attributes.Add("data-fieldName", fieldName); } if (_isConditionalForm) { List <ConditionalRule> ruleSet = BuildConditionalRuleSet(); if (ruleSet.Count > 0) { string logicalFields = Helpers.SerializeJSON(ruleSet.SelectMany(r => r.Fields).Distinct().ToArray()); string js = Helpers.SerializeJSON <List <ConditionalRule> >(ruleSet); string scriptBlock = String.Format(CultureInfo.InvariantCulture, "<script>$(document).ready(function() {{\nvar logicalForm = new LogicalForms();\nlogicalForm.validationGroup = \"{0}\";\nlogicalForm.switches = {1};\nlogicalForm.switchers = {2};\nlogicalForm.run(); \n}});</script><style>.lf-hidden {{display: none;}}</style>", this.ValidationGroup, js, logicalFields); this.Container.Controls.Add(new LiteralControl(scriptBlock)); } } } } }