This is a migrated thread and some comments may be shown as answers.

Problem using MOSSRadEditor in Custom Field SharePoint

1 Answer 111 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
waterit
Top achievements
Rank 1
waterit asked on 26 Dec 2008, 08:30 AM

I try create MossRadEditor Custom Field in SharePoint when build & debug I run pass but on webpage error "An unexpected error has occurred" :(.

file ascx:

<%@ Control Language="C#" Debug=true %>
<%@ Register Assembly="RadEditorSharePoint, Version=5.3.0.0, Culture=neutral, PublicKeyToken=1f131a624888eeed" 
Namespace="Telerik.SharePoint" TagPrefix="cc1" %>
<%@ Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint.WebControls" %>   
<SharePoint:RenderingTemplate ID="CMSDropDownFieldControl" runat="server"> 
<Template>
<cc1:MOSSRadEditor ID="MOSSRadEditor1" runat="server" Width ="450px" Height ="400px">
</cc1:MOSSRadEditor> 
</Template>
</SharePoint:RenderingTemplate>

CMSDropDownFieldControl.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebControls;

using System.Security.Principal;
using System.Security.Permissions;

using Microsoft.SharePoint;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using Telerik.SharePoint;

namespace Prevail.CMS.CustomFields
{
    class CMSDropDownFieldControl : BaseFieldControl
    {
        protected MOSSRadEditor mossRadEditor;

        protected override string DefaultTemplateName
        {
            get
            {
                return "CMSDropDownFieldControl";
            }
        }

        public override object Value
        {
            get
            {
                EnsureChildControls();
                return mossRadEditor.Text;
            }

            set
            {
                EnsureChildControls();
                mossRadEditor.Text = (string)this.ItemFieldValue;
            }
        }

        public override void Focus()
        {
            EnsureChildControls();           
        }

        protected override void CreateChildControls()
        {
            if (Field == null) return;
            base.CreateChildControls();
            try
            {

                if (ControlMode == Microsoft.SharePoint.WebControls.SPControlMode.Display)
                    return;                           
                mossRadEditor = (MOSSRadEditor)TemplateContainer.FindControl("MOSSRadEditor1");               
            }
            catch (SPException ex)
            {
               
            }

        }
    }
}

CMSDropDownField.cs
using System; 
using System.Collections.Generic; 
using System.Text; 
using Microsoft.SharePoint; 

namespace Prevail.CMS.CustomFields  
 { 
    public class CMSDropDownField:SPFieldText   

{

#region
Constructors
public CMSDropDownField(SPFieldCollection fields, string fieldName) : base(fields, fieldName)
 
 {

}

public CMSDropDownField(Microsoft.SharePoint.SPFieldCollection fields, string typeName, string displayName) : base(fields, typeName, displayName)
{
}
#endregion

/// <summary> 
/// Here we can apply formating to our number that will show up on the edit page.
/// </summary>
/// <param name="value"></param>  
/// <returns></returns>
public override object GetFieldValue(string value)  
{
if (String.IsNullOrEmpty(value))  
return null; 
return value;
}
public override Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl  
{
get
{

Microsoft.SharePoint.WebControls.BaseFieldControl _CMSDropDownFieldControl = new CMSDropDownFieldControl();
 _CMSDropDownFieldControl.FieldName = InternalName;
return _CMSDropDownFieldControl;  
}

}

}

}

1 Answer, 1 is accepted

Sort by
0
Stanimir
Telerik team
answered on 29 Dec 2008, 10:43 AM
Hi waterit,

There is an article in our online help called Using RadEditor in Web Content Management scenario . Please review the Using  SharePoint Designer part of it. I think that you will find this helpful.

In addition could you please tell us what exactly was the unexpected error.

Thank you.


Sincerely yours,
Stanimir
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Sharepoint Integration
Asked by
waterit
Top achievements
Rank 1
Answers by
Stanimir
Telerik team
Share this question
or