Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sufyan 6 posts 26 karma points
    Aug 17, 2011 @ 15:05
    Sufyan
    0

    Issue in creating datatype using telrik rad controls

    I am creating new datatype in render control usinf Tim 3 classes way but did not find teh control in render control drop down 
    Classes Code: 

    namespace umb.etx.telrichControl

    {

        class richPrevalueEditor: System.Web.UI.WebControls.PlaceHolder, umbraco.interfaces.IDataPrevalue

        {

            #region IDataPrevalue Members

     

            // referenced datatype

            private umbraco.cms.businesslogic.datatype.BaseDataType _datatype;

     

     

            private TextBox _txtLimit;

     

            public richPrevalueEditor(umbraco.cms.businesslogic.datatype.BaseDataType DataType)

            {

     

                _datatype = DataType;

                setupChildControls();

     

            }

     

            private void setupChildControls()

            {

     

                _txtLimit = new TextBox();

                _txtLimit.ID = "txtLimit";

                _txtLimit.CssClass = "umbEditorTextField";

     

     

                Controls.Add(_txtLimit);

     

            }

     

     

     

            public Control Editor

            {

                get

                {

                    return this;

                }

            }

     

     

            protected override void OnLoad(EventArgs e)

            {

                base.OnLoad(e);

                if (!Page.IsPostBack)

                {

     

                    if (Configuration.Length > 0)

                    {

     

                        _txtLimit.Text = Configuration;

     

                    }

                    else

                    {

                        _txtLimit.Text = "100";

                    }

     

     

                }

     

     

            }

     

            public void Save()

            {

                _datatype.DBType = (umbraco.cms.businesslogic.datatype.DBTypes)Enum.Parse(typeof(umbraco.cms.businesslogic.datatype.DBTypes), DBTypes.Ntext.ToString(), true);

     

     

                string data = _txtLimit.Text;

     

                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", data));

     

            }

     

            protected override void Render(HtmlTextWriter writer)

            {

                writer.WriteLine("<table>");

                writer.Write("<tr><th>Character Limit:</th><td>");

                _txtLimit.RenderControl(writer);

                writer.Write("</td></tr>");

                writer.Write("</table>");

            }

     

            public string Configuration

            {

                get

                {

                    object conf =

                       SqlHelper.ExecuteScalar<object>("select value from cmsDataTypePreValues where datatypenodeid = @datatypenodeid",

                                               SqlHelper.CreateParameter("@datatypenodeid", _datatype.DataTypeDefinitionId));

     

                    if (conf != null)

                        return conf.ToString();

                    else

                        return "";

     

                }

            }

     

            #endregion

     

            public static ISqlHelper SqlHelper

            {

                get

                {

                    return Application.SqlHelper;

                }

            }

        }

    }

    namespace umb.etx.telrichControl
    {
        class richDataType : umbraco.cms.businesslogic.datatype.BaseDataType, umbraco.interfaces.IDataType
        {
            private umbraco.interfaces.IDataEditor _Editor;
            private umbraco.interfaces.IData _baseData;
            private richPrevalueEditor _prevalueeditor;
            public override umbraco.interfaces.IDataEditor DataEditor
            {
                get
                {
                    if (_Editor == null)
                        _Editor = new richDataEditor(Data, ((richPrevalueEditor)PrevalueEditor).Configuration);
                    return _Editor;
                }
            }
            public override umbraco.interfaces.IData Data
            {
                get
                {
                    if (_baseData == null)
                        _baseData = new umbraco.cms.businesslogic.datatype.DefaultData(this);
                    return _baseData;
                }
            }
            public override Guid Id
            {
                get { return new Guid("ABF938F4-D620-4F03-9680-DF19A1C4C7DF"); }
            }
            public override string DataTypeName
            {
                get { return "Tel Rich Text"; }
            }
            public override umbraco.interfaces.IDataPrevalue PrevalueEditor
            {
                get
                {
                    if (_prevalueeditor == null)
                        _prevalueeditor = new richPrevalueEditor(this);
                    return _prevalueeditor;
                }
            }
        }
    }
    namespace umb.etx.telrichControl
    {
        class richDataEditor : System.Web.UI.UpdatePanel, umbraco.interfaces.IDataEditor
        {
     
            private umbraco.interfaces.IData _data;
               
            private string CharLimit;
     
            private Telerik.Web.UI.RadEditor txtRadEdit;
     
            public richDataEditor(umbraco.interfaces.IData Data, string Configuration)
            {
                _data = Data;
     
                if (Configuration.Length > 0)
                {
                    CharLimit = Configuration;
                }
                else
                {
                    CharLimit = "100";
                }
            }
     
            public virtual bool TreatAsRichTextEditor
            {
                get { return true; }
            }
     
            public bool ShowLabel
            {
                get { return true; }
            }
     
            public Control Editor { get { return this; } }
     
            public void Save()
            {
                this._data.Value = txtRadEdit.Content;
                
            }
     
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                txtRadEdit = new Telerik.Web.UI.RadEditor();
                txtRadEdit.Content = _data.Value.ToString();
                Telerik.Web.UI.EditorCssFileCollection CssFiles = txtRadEdit.CssFiles;
                CssFiles.Add("/css/master.css");
                CssFiles.Add("/css/FontStyler.css");
               
     
     
                base.ContentTemplateContainer.Controls.Add(txtRadEdit);
            }
          
        }
    }
    Any help regarding ??

  • Sufyan 6 posts 26 karma points
    Aug 17, 2011 @ 15:06
    Sufyan
    0

    Sorry dont know how to use code Tags. 

  • Sufyan 6 posts 26 karma points
    Aug 18, 2011 @ 06:44
    Sufyan
    0

    Any Help.. 

  • Sufyan 6 posts 26 karma points
    Aug 18, 2011 @ 08:01
    Sufyan
    0

    i have also developed a dll by using the same code illustrated in http://www.nibble.be/?p=62 and create package but still not luck. Am I doing mistake in creating package or any thing alse. 

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies