private void BaseSecurePage_PreRender(Object sender, EventArgs e) { if (this.CurrentSession.User.SysAdmin.ConvertTo <Boolean>()) { // Get all of the controls on the page and apply customisations. Customisation.Cache = null; UserGroup[] groupMembership = { }; if (this.CurrentSession != null && this.CurrentSession.Expiry > DateTime.Now) { groupMembership = Customisation.GetUserGroups(this.CurrentSession.User.Principal).ToArray(); } CustomisationSecurity[] customisationSecurities = UserGroup.FetchAll().Select(group => new CustomisationSecurity(group.Principal)).ToArray(); string pageLoc = GetPageLocation(); Customisation[] customisations = Customisation.GetFromUI(this, pageLoc, groupMembership, customisationSecurities).ToArray(); customisations.Execute(customisation => customisation.InitialiseControl(groupMembership)); // Register the customisations with the client-side script. string sScript = @" consensus.web.customisation.data = " + RestHandler.Serializer.Serialize(customisations) + @"; consensus.web.customisation.url = " + HttpUtility.JavaScriptStringEncode(pageLoc, true) + @"; consensus.web.customisation.blockCustomFields = " + BlockCustomFields.ToString().ToLower() + @"; "; // Get custom fields and prepare serialisation to exclude the CustomFieldValues element (which would get values for all records) if (!BlockCustomFields) { object baseObject; PropertyInfo dataInfo = getDataInfo(out baseObject); string dataURL = GetDataUrl(dataInfo); string tableName = GetTableName(dataInfo, baseObject); Dictionary <Type, List <string> > exclude = new Dictionary <Type, List <string> >(); exclude.Add(typeof(UserInterface.ScreenCustomField), new List <string>() { "CustomFieldValues" }); var excludingSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); excludingSerializer.RegisterConverters(new System.Web.Script.Serialization.JavaScriptConverter[] { new RestSerializer() { Ignore = exclude } }); sScript += @" consensus.web.customisation.customFields = " + excludingSerializer.Serialize(CustomFields) + @"; consensus.web.customisation.page = " + HttpUtility.JavaScriptStringEncode(pageLoc, true) + @"; consensus.web.customisation.dataurl = " + HttpUtility.JavaScriptStringEncode(dataURL, true) + @"; consensus.web.customisation.tableName = " + HttpUtility.JavaScriptStringEncode(tableName, true) + @"; "; } this.ClientScript.RegisterClientScriptBlock(this.GetType(), "CustomisationJS", sScript, true); } }