public DataEditor(IData data, TextFieldPreviewablePrevalueModel prevalueModel)
        {
            Data = data;
            TextFieldPreviewablePrevalueModel = prevalueModel;

            Page page = HttpContext.Current.CurrentHandler as Page;
            if (page != null)
            {
                _editorControl = (DataEditorControl)page.LoadControl("/Umbraco/TextFieldPreviewable/InfoCaster.Umbraco.TextFieldPreviewable.UI.DataEditorControl.ascx");
                _editorControl.DataEditor = this;
            }
        }
 public static string Serialize(TextFieldPreviewablePrevalueModel value)
 {
     return _javaScriptSerializer.Serialize(value);
 }
        public void Save()
        {
            _datatype.DBType = DBTypes.Ntext;

            PrevalueEditorControl prevalueEditorControl = Editor as PrevalueEditorControl;
            TextFieldPreviewablePrevalueModel prevalueModel = new TextFieldPreviewablePrevalueModel()
            {
                FontFamily = prevalueEditorControl.FontFamily,
                FontSize = prevalueEditorControl.FontSize,
                LineHeight = prevalueEditorControl.LineHeight,
                BoxWidth = prevalueEditorControl.BoxWidth,
                BoxHeight = prevalueEditorControl.BoxHeight
            };
            TextMode textMode;
            prevalueModel.TextMode = Enum.TryParse<TextMode>(prevalueEditorControl.TextMode, out textMode) ? textMode : TextMode.SingleLine;
            FontWeight fontWeight;
            prevalueModel.FontWeight = Enum.TryParse<FontWeight>(prevalueEditorControl.FontWeight, true, out fontWeight) ? fontWeight : FontWeight.Normal;

            SqlHelper.ExecuteNonQuery("delete from cmsDataTypePreValues where datatypenodeid = @dtdefid", SqlHelper.CreateParameter("@dtdefid", _datatype.DataTypeDefinitionId));
            SqlHelper.ExecuteNonQuery("insert into cmsDataTypePreValues (datatypenodeid, [value], sortorder, alias) values (@dtdefid, @value, 0, '')", SqlHelper.CreateParameter("@dtdefid", _datatype.DataTypeDefinitionId), SqlHelper.CreateParameter("@value", TextFieldPreviewablePrevalueModelSerializer.Serialize(prevalueModel)));
        }