+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Deleting unnecessary fields??

Deleting unnecessary fields??

7 posts, 0 answered
  1. Rick
    Rick avatar
    29 posts
    Registered:
    28 Oct 2009
    18 Jan 2010
    Link to this post
    Hi,

    I have implemented a pluggable module working exactly same as Events module.
    I did not need Content Editor for my module, so I got rid of that control (Line 36 to 227) in TrainingSessionNewView.ascx.
    1 <%@ Control Language="C#" %> 
    2 <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls" Assembly="Telerik.Cms.Engine" %> 
    3 <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls.Admin" Assembly="Telerik.Cms.Engine" %> 
    4  
    5 <%@ Register TagPrefix="sfEvn" Namespace="Telerik.Events.WebControls.Admin" Assembly="Telerik.Events" %> 
    6 <%@ Register TagPrefix="sfGCn" Namespace="Telerik.Cms.Engine.WebControls" Assembly="Telerik.Cms.Engine" %> 
    7 <!-- added for Documents --> 
    8 <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %> 
    9  
    10 <div class="ToolsAll">  
    11     <div class="backWrapp">  
    12         <asp:HyperLink ID="BackButton1" CssClass="actions back" runat="server">  
    13             <asp:Literal ID="Literal1" Text="<%$Resources:BackToAllTraining %>" runat="server" /> 
    14         </asp:HyperLink> 
    15     </div> 
    16 </div> 
    17 <div id="divWorkArea" runat="server" class="workArea insert">  
    18     <telerik:MessageControl runat="server" ID="message1">  
    19         <ItemTemplate> 
    20             <asp:Label runat="server" ID="messageText"></asp:Label> 
    21         </ItemTemplate> 
    22     </telerik:MessageControl> 
    23     <div class="mainForm">  
    24         <class="mand"><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:MandatoryFields %>"></asp:Literal></p>  
    25         <h3><asp:Label ID="Label1" AssociatedControlID="Name" runat="server">  
    26             <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Name %>"></asp:Literal> 
    27             * <em id="NameLabel" runat="server"></em> 
    28         </asp:Label></h3>  
    29         <fieldset class="set">  
    30             <div class="setIn title">  
    31                 <asp:TextBox ID="Name" Text="<%$Resources:NameInput %>" runat="server"></asp:TextBox> 
    32                 <asp:RequiredFieldValidator ID="validator1" runat="server" ControlToValidate="Name" Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"><strong><asp:Literal ID="Literal4" runat="server" Text="<%$Resources:NameEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator> 
    33             </div> 
    34         </fieldset> 
    35         <div class="bottom"><div><!-- --></div></div> 
    36         <%--<h3> 
    37             <asp:Literal ID="Literal5" runat="server" Text="<%$Resources:Content %>"></asp:Literal> 
    38             * <em id="contentEditorLabel" runat="server"></em> 
    39         </h3> 
    40         <fieldset class="set">  
    41             <div class="setIn">  
    42                 <telerik:RadEditor   
    43                     runat="server"   
    44                     ID="Editor"   
    45                     ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css" 
    46                     ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"                      
    47                     Skin="WebBlue" 
    48                     NewLineBr="False"   
    49                     DialogsCssFile ="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css" 
    50                     Width="95%">   
    51                     <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" /> 
    52                     <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" /> 
    53                     <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" /> 
    54                     <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" /> 
    55                     <CssFiles> 
    56                         <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" /> 
    57                     </CssFiles> 
    58  
    59                 </telerik:RadEditor> 
    60                 <script type="text/javascript">  
    61  
    62                             Telerik.Web.UI.Editor.CommandList["LibraryImageManager"] = function(commandName, editor, args)  
    63                             {  
    64                                var editoreditorArgs = editor.getSelectedElement();  
    65                                if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")  
    66                                     editoreditorArgs = editor.getSelection();  
    67                                  
    68                                var myCallbackFunction = function(sender, args)  
    69                                {  
    70                                     if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "IMG")  
    71                                         args.parentNode.replaceChild(editorArgs, args);  
    72                                     else  
    73                                     {  
    74                                         var cloned = args.cloneNode(true);  
    75                                         var div = args.ownerDocument.createElement("DIV");  
    76                                         div.appendChild(cloned);  
    77                                         editorArgs.pasteHtml(div.innerHTML);  
    78                                     }  
    79                                }  
    80                                editor.showExternalDialog(  
    81                                '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx") %>',  
    82                                editorArgs,   
    83                                750,   
    84                                600,   
    85                                myCallbackFunction,   
    86                                null,   
    87                                'ImageLibraryDialog',   
    88                                true,   
    89                                Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,   
    90                                false,   
    91                                true)  
    92                             };  
    93                               
    94                             Telerik.Web.UI.Editor.CommandList["LibraryDocumentManager"] = function(commandName, editor, args)  
    95                             {  
    96                                var editoreditorArgs = editor.getSelectedElement();  
    97                                if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")  
    98                                     editoreditorArgs = editor.getSelection();  
    99                                  
    100                                var myCallbackFunction = function(sender, args)  
    101                                {  
    102                                     if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")  
    103                                         args.parentNode.replaceChild(editorArgs, args);  
    104                                     else  
    105                                     {  
    106                                         var cloned = args.cloneNode(true);  
    107                                         var div = args.ownerDocument.createElement("DIV");  
    108                                         div.appendChild(cloned);  
    109                                         editorArgs.pasteHtml(div.innerHTML);  
    110                                     }  
    111                                }  
    112                                editor.showExternalDialog(  
    113                                '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/DocumentEditorDialog.aspx") %>',  
    114                                editorArgs,   
    115                                750,   
    116                                600,   
    117                                myCallbackFunction,   
    118                                null,   
    119                                'ImageLibraryDialog',   
    120                                false,   
    121                                Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,   
    122                                false,   
    123                                true)  
    124                             };  
    125  
    126                             Telerik.Web.UI.Editor.CommandList["LinkManager"] = function(commandName, editor, args)  
    127                             {  
    128                                var editoreditorArgs = editor.getSelectedElement();  
    129                                if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")  
    130                                {                                                                     
    131                                     var sel = editor.getSelection();    
    132                                     editorArgs = sel;  
    133                                     editorArgs.Html = sel.getHtml();  
    134                                     editorArgs.Text = sel.getText();                                      
    135                                }       
    136                                       
    137                                  
    138                                var myCallbackFunction = function(sender, args)  
    139                                {  
    140                                     if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")  
    141                                         args.parentNode.replaceChild(editorArgs, args);  
    142                                     else  
    143                                     {  
    144                                         var cloned = args.cloneNode(true);  
    145                                         var div = args.ownerDocument.createElement("DIV");  
    146                                         div.appendChild(cloned);  
    147                                         editorArgs.pasteHtml(div.innerHTML);  
    148                                     }  
    149                                }  
    150                                editor.showExternalDialog(  
    151                                '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',  
    152                                editorArgs,   
    153                                750,   
    154                                600,   
    155                                myCallbackFunction,   
    156                                null,   
    157                                'ImageLibraryDialog',   
    158                                false,   
    159                                Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,   
    160                                false,   
    161                                true)  
    162                             };  
    163                               
    164                             Telerik.Web.UI.Editor.CommandList["SetLinkProperties"] = function(commandName, editor, args)  
    165                             {  
    166                                var editoreditorArgs = editor.getSelectedElement();  
    167                                if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")  
    168                                     editoreditorArgs = editor.getSelection();  
    169                                  
    170                                var myCallbackFunction = function(sender, args)  
    171                                {  
    172                                     if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")  
    173                                         args.parentNode.replaceChild(editorArgs, args);  
    174                                     else  
    175                                     {  
    176                                         var cloned = args.cloneNode(true);  
    177                                         var div = args.ownerDocument.createElement("DIV");  
    178                                         div.appendChild(cloned);  
    179                                         editorArgs.pasteHtml(div.innerHTML);  
    180                                     }  
    181                                }  
    182                                editor.showExternalDialog(  
    183                                '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',  
    184                                editorArgs,   
    185                                750,   
    186                                600,   
    187                                myCallbackFunction,   
    188                                null,   
    189                                'ImageLibraryDialog',   
    190                                false,   
    191                                Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,   
    192                                false,   
    193                                true)  
    194                             };  
    195                             var oldFunction = Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"]; //save the original Paste function  
    196  
    197                             Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"] = function(commandName, editor, args)  
    198                             {  
    199                                 oldFunction(commandName, editor, args);  
    200                                 var bd = document.getElementsByTagName("body")[0];  
    201                                   
    202                                 if(/fullScreenMode/.test(bd.className)) {  
    203                                     var rep = bd.className.match(' '+'fullScreenMode')?' '+'fullScreenMode':'fullScreenMode';  
    204                                     bdbd.className=bd.className.replace(rep,'');  
    205  
    206                                 } else {  
    207                                     bd.className += bd.className?' '+'fullScreenMode':'fullScreenMode';  
    208                                 }  
    209                             };  
    210  
    211                             // automated tests helper function  
    212                             function InsertTextArea()  
    213                             {   
    214                                 var editor = $find('<%=Editor.ClientID%>');  
    215                                 editor.set_html('<textarea id="myTableToFind" style="overflow:hidden; height: 300px; width: 500px;" border="none"></textarea>');   
    216                             }  
    217  
    218                             </script> 
    219                 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Editor" 
    220                     Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True"><strong><asp:Literal ID="Literal6" runat="server" Text="<%$Resources:ContentEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator> 
    221             </div> 
    222         </fieldset> 
    223         <div class="bottom">  
    224             <div> 
    225                 <!-- --> 
    226             </div> 
    227         </div>--%> 
    228  
    229         <sf:ContentMetaFields ID="MetaFields" runat="server">  
    230             <ItemTemplate> 
    231               
    232                 <!-- Location --> 
    233                 <h3> 
    234                     <asp:Literal ID="ltrEventLocation" runat="server" Text="<%$Resources:Location %>" /></h3>  
    235                 <fieldset class="set">  
    236                     <div class="setIn">  
    237                         <class="example">  
    238                             <asp:Literal ID="ltrEventLocationNote" runat="server" Text='<%$Resources:LocationNote %>' /> 
    239                         </p> 
    240                         <ol> 
    241                             <li> 

    And this is TrainingSessionNewView.cs
    1 using System;  
    2 using System.Collections.Generic;  
    3 using System.Linq;  
    4 using System.Text;  
    5 using Telerik.Cms.Engine.WebControls.Admin;  
    6  
    7 namespace Snowden.Training.WebControls.Admin.TrainingSession  
    8 {  
    9     public class TrainingSessionNewView : ContentItemNew<TrainingSessionView> 
    10     {  
    11         #region View layout and template  
    12  
    13         /// <summary> 
    14         /// Gets or sets the path to a custom layout template for the control.  
    15         /// </summary> 
    16         /// <value></value>  
    17         [WebSysTemplate(TrainingSessionNewView.layoutTemplateName, "TrainingSessionNewView_Template_Desc", "/Training", false, "2009-04-10")]  
    18         public override string LayoutTemplatePath  
    19         {  
    20             get  
    21             {  
    22                 return base.LayoutTemplatePath;  
    23             }  
    24             set  
    25             {  
    26                 base.LayoutTemplatePath = value;  
    27             }  
    28         }  
    29  
    30         /// <summary> 
    31         /// Gets the name of the embedded layout template. If the control uses layout template this  
    32         /// property must be overridden to provide the path (key) to an embedded resource file.  
    33         /// </summary> 
    34         /// <value></value>  
    35         protected override string LayoutTemplateName  
    36         {  
    37             get  
    38             {  
    39                 return TrainingSessionNewView.layoutTemplateName;  
    40             }  
    41         }  
    42  
    43         private const string layoutTemplateName =  
    44             "Snowden.Training.Resources.ControlTemplates.Backend.TrainingSessionNewView.ascx";  
    45  
    46         #endregion  
    47  
    48         #region Command overrides  
    49  
    50         /* by overrideing the commands we can make the base module behave differently, while  
    51          * keeping all of its base functionality */  
    52  
    53         /// <summary> 
    54         /// Gets the edit command.  
    55         /// </summary> 
    56         /// <param name="itemId">The item id.</param> 
    57         /// <returns></returns>  
    58         protected override string GetEditCommand(Guid itemId)  
    59         {  
    60             return CreateHostViewCommand<TrainingSessionEditView>(itemId.ToString());  
    61         }  
    62  
    63         /// <summary> 
    64         /// Gets the history command.  
    65         /// </summary> 
    66         /// <param name="itemId">The item id.</param> 
    67         /// <returns></returns>  
    68         protected override string GetHistoryCommand(Guid itemId)  
    69         {  
    70             return CreateHostViewCommand<TrainingSessionHistoryView>(itemId.ToString());  
    71         }  
    72  
    73         /// <summary> 
    74         /// Gets the list command.  
    75         /// </summary> 
    76         /// <returns></returns>  
    77         protected override string GetListCommand()  
    78         {  
    79             return CreateHostViewCommand<TrainingSessionItemsListView>();  
    80         }  
    81  
    82         /// <summary> 
    83         /// Gets the preview command.  
    84         /// </summary> 
    85         /// <param name="itemId">The item id.</param> 
    86         /// <returns></returns>  
    87         protected override string GetPreviewCommand(Guid itemId)  
    88         {  
    89             return CreateHostViewCommand<TrainingSessionPreviewView>(itemId.ToString());  
    90         }  
    91  
    92         #endregion  
    93  
    94         #region Security overrides  
    95  
    96         /* by overriding the permissions methods, we can substitute the permissions for generic content  
    97          * module with permissions for products module, while we leave the base class to perform the  
    98          * business logic based on these permissions */  
    99  
    100         /// <summary> 
    101         /// Checks the permission.  
    102         /// </summary> 
    103         /// <param name="contentOwnerId">The content owner id.</param> 
    104         /// <param name="requestRights">The request rights.</param> 
    105         /// <returns></returns>  
    106         public override bool CheckPermission(Guid contentOwnerId, int requestRights)  
    107         {  
    108             return this.Host.TrainingManager.GetPermission(contentOwnerId, requestRights).CheckDemand();  
    109         }  
    110  
    111         /// <summary> 
    112         /// Checks the permission.  
    113         /// </summary> 
    114         /// <param name="right">The right.</param> 
    115         /// <param name="currState">State of the curr.</param> 
    116         /// <returns></returns>  
    117         protected override bool CheckPermission(int right, Telerik.Cms.Engine.IContent currState)  
    118         {  
    119             return this.Host.TrainingManager.GetPermission(currState, right).CheckDemand();  
    120         }  
    121  
    122         /// <summary> 
    123         /// Demands the permission.  
    124         /// </summary> 
    125         /// <param name="right">The right.</param> 
    126         protected override void DemandPermission(int right)  
    127         {  
    128             this.Host.TrainingManager.GetPermission(right).Demand();  
    129         }  
    130  
    131         /// <summary> 
    132         /// Demands the permission.  
    133         /// </summary> 
    134         /// <param name="right">The right.</param> 
    135         /// <param name="currState">State of the curr.</param> 
    136         protected override void DemandPermission(int right, Telerik.Cms.Engine.IContent currState)  
    137         {  
    138             this.Host.TrainingManager.GetPermission(currState, right).Demand();  
    139         }  
    140  
    141         #endregion  
    142     }  
    143 }  
    144  

    After that, I got this error :
    1 Server Error in '/SnowdenWebsite' Application.  
    2 --------------------------------------------------------------------------------  
    3  
    4 A required control was not found in the template for "Snowden.Training.Resources.ControlTemplates.Backend.TrainingSessionNewView.ascx". The control must be assignable form type "System.Web.UI.IEditableTextControl" and must have ID "Editor".   
    5 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
    6  
    7 Exception Details: Telerik.Cms.Web.UI.TemplateException: A required control was not found in the template for "Snowden.Training.Resources.ControlTemplates.Backend.TrainingSessionNewView.ascx". The control must be assignable form type "System.Web.UI.IEditableTextControl" and must have ID "Editor".  
    8  
    9 Source Error:   
    10  
    11 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.    
    12  
    13 Stack Trace:   
    14  
    15  
    16 [TemplateException: A required control was not found in the template for "Snowden.Training.Resources.ControlTemplates.Backend.TrainingSessionNewView.ascx". The control must be assignable form type "System.Web.UI.IEditableTextControl" and must have ID "Editor".]  
    17    Telerik.Cms.Web.UI.GenericContainer.ThrowException(Type requiredType, String controlId) +87  
    18    Telerik.Cms.Web.UI.GenericContainer.GetControl(String id, Boolean required) +271  
    19    Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.get_Editor() +68  
    20    Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.SetContentForm(IContent cnt) +967  
    21    Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.InitializeControls(Control viewContainer) +73  
    22    Telerik.Cms.Engine.WebControls.Admin.ContentItemNew`1.InitializeControls(Control viewContainer) +37  
    23    Telerik.Cms.Web.UI.ViewModeControl`1.CreateChildControls() +155  
    24    System.Web.UI.Control.EnsureChildControls() +87  
    25    System.Web.UI.Control.PreRenderRecursiveInternal() +44  
    26    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    27    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    28    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    29    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    30    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    31    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    32    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    33    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    34    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    35    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    36    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    37    System.Web.UI.Control.PreRenderRecursiveInternal() +171  
    38    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842  
    39  
    40    
    41  
    42  
    43 --------------------------------------------------------------------------------  
    44 Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3601  

    Why is this happening?
    Am I not allowed to get rid of any control?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Jan 2010
    Link to this post
    Hello Rick,

    The RadEditor control with ID is required for the view. You may set the control as not required following the logic from this post.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Rick
    Rick avatar
    29 posts
    Registered:
    28 Oct 2009
    11 Feb 2010
    Link to this post
    Hi,

    I followed the post you recommended and could get rid of Editor control successfully.
    However, now other controls are not working such as BackButton1 and Save button.
    Do I have to implement them manually because I created new class?
    (Previously, it was done by Sitefinity behind the scene)

    And how do I know that the class is using the templates under "~/Sitefinity/ControlTemplates/Training" folder?

    Thanks,
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Feb 2010
    Link to this post
    Hi Rick,

    All buttons should work if you have correctly replaced the RadEditor in all instances where it is used.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  5. Rick
    Rick avatar
    29 posts
    Registered:
    28 Oct 2009
    11 Feb 2010
    Link to this post
    Hi,

    I have created CustomPhotoCompEditView.cs in App_Code.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Snowden.PhotoComp.WebControls.Admin;
    using Telerik.Cms.Engine.WebControls.Admin;
    using System.Web.UI;
    using Telerik.Cms.Engine;
    using System.Web.UI.WebControls;
    using Telerik.Security.Permissions;
    using Snowden.PhotoComp;
      
    /// <summary>
    /// Summary description for CustomPhotoCompEditView
    /// </summary>
    public class CustomPhotoCompEditView : ContentItemEdit<PhotoCompView>
    {
        #region Properties
      
        public override System.Type AssemblyInfo
        {
            get
            {
                return typeof(PhotoCompControlPanel);
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
      
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return typeof(PhotoCompControlPanel);
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
      
        protected override System.Web.UI.IEditableTextControl Editor
        {
            get
            {
                return base.Container.GetControl<IEditableTextControl>("Editor", false);
            }
        }
      
        #endregion
      
        protected override void InitializeControls(Control viewContainer)
        {
            IContent content = null;
            Guid contentId = Guid.Empty;
            if (this.Page.Request.QueryString[this.ParameterKey] != null)
            {
                contentId = new Guid(this.Page.Request.QueryString[this.ParameterKey]);
                content = this.Host.Manager.GetContent(contentId);
            }
      
            this.SaveButton1.CommandName = "Save";
            this.SaveButton1.CommandArgument = contentId.ToString();
            this.SaveButton1.Command += this.EditContentsButtons_Command;
      
             
        }
      
        private void EditContentsButtons_Command(object sender, CommandEventArgs e)
        {
            Guid contentId = new Guid(e.CommandArgument.ToString());
            IContent content = this.Host.Manager.GetContent(contentId);
      
            switch (e.CommandName)
            {
                case "Cancel":
                    break;
                case "Save" :
                    this.Host.Manager.GetPermission(CrudRights.Modify).Demand();
                    SaveContent(content);
                    break;
                case "ShowParent" :
                    break;
            }
        }
      
        public void SaveContent(IContent content)
        {
            PhotoCompManager photoCompManager = new PhotoCompManager("PhotoComp");
            foreach (var metaKey in photoCompManager.Content.Provider.MetaKeys)
            {
                if (metaKey.Value.ValueType == MetaValueTypes.Boolean)
                {
                    System.Web.UI.ICheckBoxControl metaKeyValue = (ICheckBoxControl)this.FindControl(metaKey.Key);
                    if (metaKeyValue != null)
                    {
                        content.SetMetaData(metaKey.Key, metaKeyValue.Checked);
                    }
                }
                else
                {
                    ITextControl metaKeyValue = (ITextControl)this.FindControl(metaKey.Key);
                    if (metaKeyValue != null)
                    {
                        content.SetMetaData(metaKey.Key, metaKeyValue.Text);
                    }
                }
            }
        }
          
    }

    And Telerik.Sitefinity.Configuration.ControlsConfig.xml
    <?xml version="1.0" encoding="utf-8"?>
    <controlsConfig>
      <viewMap>
        <viewSettings hostType="Snowden.PhotoComp.WebControls.Admin.PhotoCompView, Snowden.PhotoComp">
          <views>
            <remove name="PhotoCompEditView"></remove>
            <add name="PhotoCompEditView" viewType="CustomPhotoCompEditView, App_Code"></add>
            <remove name="PhotoCompNewView"></remove>
            <add name="PhotoCompNewView" viewType="CustomPhotoCompNewView, App_Code"></add>
          </views>
        </viewSettings>
          
        <viewSettings hostType="CustomPhotoCompEditView, App_Code" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/PhotoComp/PhotoCompEditView.ascx">
        </viewSettings>
        <viewSettings hostType="CustomPhotoCompNewView, App_Code" layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/PhotoComp/PhotoCompNewView.ascx">
        </viewSettings>

     

    My original PhotoCompEditView is in a separate project (not inside Sitefinity project).
    Is that the reason I lost functionalities?

    Thanks,

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Feb 2010
    Link to this post
    Hi Rick,

    The sample is made for comments and you are pasting the code from the sample in view that inherits from ContentItemEdit.

    1. Override SetContentForm and use your custom editor

    this.CustomEditor.Text = LinkParser.ResolveLinks(cnt.Content as string, ContentManager.ResolveItemUrl, null, true, false);
     this.MetaFields.Content = cnt;

    2. Override SaveContent()

    cnt.Content = LinkParser.UnresolveLinks(CustomEditor.Text);

    If you do not want to have a content area you have just to set the RadEditor as not required control.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  7. Rick
    Rick avatar
    29 posts
    Registered:
    28 Oct 2009
    12 Feb 2010
    Link to this post
    Hi,

    Yes, I only want to get rid of RadEditor but keep other controls and meta fileds.
    I only set the RadEditor as not required control.
    using System;  
    using Snowden.PhotoComp.WebControls.Admin;
    using Telerik.Cms.Engine.WebControls.Admin;
    using System.Web.UI;
    using Telerik.Cms.Engine;
      
    /// <summary>
    /// Summary description for CustomPhotoCompEditView
    /// </summary>
    public class CustomPhotoCompEditView : ContentItemEdit<PhotoCompView>
    {
        #region Properties
      
        public override System.Type AssemblyInfo
        {
            get
            {
                return typeof(PhotoCompControlPanel);
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
      
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return typeof(PhotoCompControlPanel);
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
      
        protected override System.Web.UI.IEditableTextControl Editor
        {
            get
            {
                return base.Container.GetControl<IEditableTextControl>("Editor", false);
            }
        }
      
        #endregion
      
        protected override void InitializeControls(Control viewContainer)
        {
            IContent content = null;
            Guid contentId = Guid.Empty;
            if (this.Page.Request.QueryString[this.ParameterKey] != null)
            {
                contentId = new Guid(this.Page.Request.QueryString[this.ParameterKey]);
                content = this.Host.Manager.GetContent(contentId);
            }
      
        }
      
    }

    When I go to Edit mode, data previously stored does not show up and BackButton1 still not working.

    I am very confused with this.
    Basically, putting this code in App_Code is just overriding the actual code?
    Or, is this replacing?

    Please let me know what I have missed.

    Thanks,
Register for webinar
7 posts, 0 answered