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

Forums / Developing with Sitefinity / Error when saving an item in a custom module

Error when saving an item in a custom module

11 posts, 0 answered
  1. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    04 Mar 2010
    Link to this post

    Hi All,

    I am working on a new custom module called Rankings which suprisingly has a meta field called Ranking. This meta field is defined in the web.config as follows.

    <

     

    add key="Rankings.Ranking" valueType="Integer" visible="True" searchable="True" sortable="True" defaultValue=""/>

     


    I need the valuetype of integer to be able to sort (correctly) on ranking. The problem is that I get the following error when I try to save any item in the module. Is there a way to solve this while retaining the valuetype integer?

    Any pointer will be appreciated. 


    David
     

    Serverfout in toepassing /.

    Cannot cast System.Int32 to string. The metadata field Ranking can accept only the following data types: string.

    Beschrijving: Er is een onverwerkte uitzondering opgetreden tijdens het uitvoeren van de huidige webaanvraag. Raadpleeg de stacktracering voor meer informatie over deze fout en de oorsprong ervan in de code.

    Details van uitzondering: System.InvalidCastException: Cannot cast System.Int32 to string. The metadata field Ranking can accept only the following data types: string.

    Fout in bron:

    Er is een onverwerkte uitzondering gegenereerd tijdens het uitvoeren van de huidige webaanvraag. Aan de hand van de onderstaande tracering van de uitzonderingsstack kunt u meer informatie verkrijgen over de oorsprong en de locatie van de uitzondering.

    Stacktracering:

    [InvalidCastException: Cannot cast System.Int32 to string. The metadata field Ranking can accept only the following data types: string.]
       Telerik.Cms.Engine.Data.MetaData.ThrowCastException(Object value, String requiredType, String acceptedTypes) +174
       Telerik.Cms.Engine.Data.MetaData.set_Value(Object value) +118
       Telerik.Cms.Engine.Data.ContentVersion.SetMetaDataInternal(Transaction tran, IMetaInfo metaInfo, Object value) +436
       Telerik.Cms.Engine.Data.ContentVersion.SetMetaData(String key, Object value) +108
       Telerik.Cms.Engine.Data.CmsContentBase.SetMetaData(String key, Object value) +22
       Telerik.Cms.Engine.StagedContent.Copy(IContent source, IContent target) +749
       Telerik.Cms.Engine.StagedContent.Publish(IContent content) +13
       Telerik.Cms.Engine.ContentManager.SavedStagedContent(StagedContent staged, ContentStatus status) +230
       Telerik.Cms.Engine.ContentManager.SaveContent(IContent content, ContentStatus status) +1267
       Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.SaveContent() +1211
       Telerik.Cms.Engine.WebControls.Admin.ContentItemEdit`1.Button_Command(Object sender, CommandEventArgs e) +62
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +108
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    


    Versiegegevens: Microsoft .NET Framework Versie:2.0.50727.4200; ASP.NET Versie:2.0.50727.4016
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Mar 2010
    Link to this post
    Hello David van Geel,

    Thank you for using our services.

    You can still set the value type to short text and use it for numbers. A sample of how to save integer and double values as meta fields accepting string values can be found in this blog post: ntegrate rating with Generic Content based modules

    All the best,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    04 Mar 2010
    Link to this post
    Sorry Radoslav,

    Based on your remark I can not pinpoint the "mechanism" I should use. Let me recap, maybe that will get things clear. So you are telling me to store the ranking as a shorttext and convert that value in the user control before the sorting is done. Is my interpretation correct?

    David
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    05 Mar 2010
    Link to this post
    Hello David van Geel,

    Since the property is integer the value should be persisted. It seems that you are entering an invalid data to this property or you are executing some logic in SaveContent method. You could try using the code snippet below to narrow down the issue. The code create a new key which MetaValueType is Integer. Then int.Parse(str) is called - MSDN - Int32.Parse Method which converts the string representation of a number to its 32-bit signed integer equivalent.

    Telerik.Cms.Engine.MetaInfo info = new  Telerik.Cms.Engine.MetaInfo("77", MetaValueTypes.Integer);
     object data = null;
     
     if (info.ValueType == MetaValueTypes.Integer)
     {
         string str = info.Key;
         if (String.IsNullOrEmpty(str))
             data = 0;
         else
             data = int.Parse(str);
     }


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    05 Mar 2010
    Link to this post
    Hi Guys,

    Still not sure what to do. As far as I can tell I did not add code to the SaveContent method and I am entering only numbers in the asp textbox for the ranking meta field. I have included the ascx en the cs files of the edit view for a ranking item. Maybe that will give you a beter idea what is happening.

    Regards,

    David


    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls" Assembly="Telerik.Cms.Engine" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls.Admin" Assembly="Telerik.Cms.Engine" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %>
    <%@ Register TagPrefix="sfEvn" Namespace="Telerik.Events.WebControls.Admin" Assembly="Telerik.Events" %>
    <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>
    <%@ Register Assembly="App_Code" Namespace="RandomSFCode.MetaMaster2008" TagPrefix="cc1" %> 
    <%@ Register TagPrefix="econtrols" Src="~/Estate/UserControls/Admin/GalleryPicker.ascx" TagName="GalleryPicker" %> 
    <%@ Register TagPrefix="econtrols" Src="~/Estate/UserControls/Admin/ListPicker.ascx" TagName="ListPicker" %> 
      
    <div class="ToolsAll">
        <asp:Label ID="lockedWarning" runat="server">
            <p class="locked">
                <strong>{0}</strong
                <asp:Literal ID="Literal4" runat="server" Text="<%$Resources:IsEditingRanking %>"></asp:Literal>
            </p>
        </asp:Label>
        <div class="backWrapp">
            <asp:HyperLink ID="BackButton1" CssClass="actions back" runat="server">
                <asp:Literal ID="Literal1" Text="<%$Resources:BackToAllRankings %>" runat="server" />
            </asp:HyperLink>
        </div>
        <telerik:RadTabStrip 
                        id="tabStrip" 
                        Align="Right" 
                        runat="server"
                        selectedindex="0" 
                        causesvalidation="false"
                        EnableEmbeddedSkins="false"
                        Skin="SitefinityPages">
                            <Tabs>
                                <telerik:RadTab Text="<%$Resources:View %>" ></telerik:RadTab>
                                <telerik:RadTab Text="<%$Resources:Edit %>" ></telerik:RadTab>
                                <telerik:RadTab Text="<%$Resources:History %>" ></telerik:RadTab>
                            </Tabs>
                        </telerik:RadTabStrip>
        <div class="clear"><!-- --></div>
    </div>
    <div id="divWorkArea" runat="server" class="workArea">
        <sf:MessageControl runat="server" id="MessageControl1">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="messageText"></asp:Label>
                    </ItemTemplate>
        </sf:MessageControl>
        <div class="mainForm">
            <p class="button_area top">
                <asp:LinkButton ID="saveButton1" runat="server" CssClass="CmsButLeft okdark">        
                    <asp:Literal ID="Literal2" runat="server" Text="<%$Resources:SaveChanges %>"></asp:Literal>
                </asp:LinkButton>
                <asp:Label ID="Literal3" runat="server" Text="<%$Resources:Or %>" />
                <asp:LinkButton ID="cancelButton1" Text="<%$Resources:Cancel %>" runat="server" CssClass="cmscclcmd" CausesValidation="false" />
            </p>
              <p class="mand">
                <asp:Literal ID="Literal5" runat="server" Text="<%$Resources:MandatoryFields %>"></asp:Literal></p>
            <h3>
                <asp:Label ID="Label1" AssociatedControlID="Name" runat="server">
                    <asp:Literal ID="Literal6" runat="server" Text="<%$Resources:Name %>"></asp:Literal>
                    * <em id="NameLabel" runat="server"></em></asp:Label></h3>
            <fieldset class="set">
                <div class="setIn title">
                    <asp:TextBox ID="Name" Text="<%$Resources:NameInput %>" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="validator1" runat="server" ControlToValidate="Name"
                        Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True">
                        <strong><asp:Literal ID="Literal14" runat="server" Text="<%$Resources:NameEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>
                </div>
            </fieldset>
            <div class="bottom"><div><!-- --></div></div>
            <h3>
                <asp:Literal ID="Literal7" runat="server" Text="<%$Resources:Content %>"></asp:Literal>
                *<em id="contentEditorLabel" runat="server"></em>
            </h3>
            <fieldset class="set">
                <div class="setIn">
                    <telerik:RadEditor 
                        runat="server" 
                        ID="Editor" 
                        ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css"
                        ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"                    
                        Skin="WebBlue"
                        NewLineBr="False" 
                        DialogsCssFile ="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css"
                        Width="95%"
                        <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
                        <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
                        <CssFiles>
                           <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" />
                        </CssFiles>
                    </telerik:RadEditor>
      
                    <script type="text/javascript">
      
                                Telerik.Web.UI.Editor.CommandList["LibraryImageManager"] = function(commandName, editor, args)
                                {
                                   var editorArgs = editor.getSelectedElement();
                                   if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                                        editorArgs = editor.getSelection();
                                     
                                   var myCallbackFunction = function(sender, args)
                                   {
                                        if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "IMG")
                                            args.parentNode.replaceChild(editorArgs, args);
                                        else
                                        {
                                            var cloned = args.cloneNode(true);
                                            var div = args.ownerDocument.createElement("DIV");
                                            div.appendChild(cloned);
                                            editorArgs.pasteHtml(div.innerHTML);
                                        }
                                   }
                                   editor.showExternalDialog(
                                   '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx") %>',
                                   editorArgs, 
                                   750, 
                                   600, 
                                   myCallbackFunction, 
                                   null, 
                                   'ImageLibraryDialog', 
                                   true, 
                                   Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                                   false, 
                                   true)
                                };
                                  
                                Telerik.Web.UI.Editor.CommandList["LibraryDocumentManager"] = function(commandName, editor, args)
                                {
                                   var editorArgs = editor.getSelectedElement();
                                   if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                                        editorArgs = editor.getSelection();
                                     
                                   var myCallbackFunction = function(sender, args)
                                   {
                                        if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                            args.parentNode.replaceChild(editorArgs, args);
                                        else
                                        {
                                            var cloned = args.cloneNode(true);
                                            var div = args.ownerDocument.createElement("DIV");
                                            div.appendChild(cloned);
                                            editorArgs.pasteHtml(div.innerHTML);
                                        }
                                   }
                                   editor.showExternalDialog(
                                   '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/DocumentEditorDialog.aspx") %>',
                                   editorArgs, 
                                   750, 
                                   600, 
                                   myCallbackFunction, 
                                   null, 
                                   'ImageLibraryDialog', 
                                   false, 
                                   Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                                   false, 
                                   true)
                                };
      
                                Telerik.Web.UI.Editor.CommandList["LinkManager"] = function(commandName, editor, args)
                                {
                                   var editorArgs = editor.getSelectedElement();
                                   if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                                   {                                                                   
                                        var sel = editor.getSelection();  
                                        editorArgs = sel;
                                        editorArgs.Html = sel.getHtml();
                                        editorArgs.Text = sel.getText();                                    
                                   }
                                     
                                   var myCallbackFunction = function(sender, args)
                                   {
                                        if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                            args.parentNode.replaceChild(editorArgs, args);
                                        else
                                        {
                                            var cloned = args.cloneNode(true);
                                            var div = args.ownerDocument.createElement("DIV");
                                            div.appendChild(cloned);
                                            editorArgs.pasteHtml(div.innerHTML);
                                        }
                                   }
                                   editor.showExternalDialog(
                                   '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                                   editorArgs, 
                                   750, 
                                   600, 
                                   myCallbackFunction, 
                                   null, 
                                   'ImageLibraryDialog', 
                                   false, 
                                   Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                                   false, 
                                   true)
                                };
                                  
                                Telerik.Web.UI.Editor.CommandList["SetLinkProperties"] = function(commandName, editor, args)
                                {
                                   var editorArgs = editor.getSelectedElement();
                                   if (!editorArgs.nodeName || typeof(editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
                                        editorArgs = editor.getSelection();
                                     
                                   var myCallbackFunction = function(sender, args)
                                   {
                                        if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "A")
                                            args.parentNode.replaceChild(editorArgs, args);
                                        else
                                        {
                                            var cloned = args.cloneNode(true);
                                            var div = args.ownerDocument.createElement("DIV");
                                            div.appendChild(cloned);
                                            editorArgs.pasteHtml(div.innerHTML);
                                        }
                                   }
                                   editor.showExternalDialog(
                                   '<%= Page.ResolveUrl("~/Sitefinity/UserControls/Dialogs/LinksDialog.aspx") %>',
                                   editorArgs, 
                                   750, 
                                   600, 
                                   myCallbackFunction, 
                                   null, 
                                   'ImageLibraryDialog', 
                                   false, 
                                   Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, 
                                   false, 
                                   true)
                                };
                                  
                                var oldFunction = Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"]; //save the original Paste function
      
                                Telerik.Web.UI.Editor.CommandList["ToggleScreenMode"] = function(commandName, editor, args)
                                {
                                    oldFunction(commandName, editor, args);
                                    var bd = document.getElementsByTagName("body")[0];
                                      
                                    if(/fullScreenMode/.test(bd.className)) {
                                        var rep = bd.className.match(' '+'fullScreenMode')?' '+'fullScreenMode':'fullScreenMode';
                                        bd.className=bd.className.replace(rep,'');
      
                                    } else {
                                        bd.className += bd.className?' '+'fullScreenMode':'fullScreenMode';
                                    }
                                };
      
                                // automated tests helper function
                                function InsertTextArea()
                                
                                    var editor = $find('<%=Editor.ClientID%>');
                                    editor.set_html('<textarea id="myTableToFind" style="overflow:hidden; height: 300px; width: 500px;" border="none"></textarea>'); 
                                }
                    </script>
      
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Editor"
                        Display="Dynamic" EnableViewState="False" CssClass="validMessage" SetFocusOnError="True">
                        <strong><asp:Literal ID="Literal8" runat="server" Text="<%$Resources:ContentEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>
                </div>
            </fieldset>
            <div class="bottom">
                <div>
                    <!-- -->
                </div>
            </div>
            <h3>
                <asp:Literal ID="Literal9" runat="server" Text="<%$Resources:Category %>"></asp:Literal>
            </h3>
            <sf:ContentMetaFields id="MetaFields" runat="server">
                <ItemTemplate>
                    <fieldset class="set">
                        <ol class="setIn">
                            <li class="catSel clearfix">
                                <asp:Label ID="Label4" AssociatedControlID="Category" runat="server">
                                <asp:Literal ID="Literal10" runat="server" Text="<%$Resources:Category %>"></asp:Literal>
                                <em id="Em1" runat="server"></em></asp:Label>
                                <sf:ContentCategoriesField ID="Category" runat="server" />
                            </li>
                        </ol>
                    </fieldset>
                    <div class="bottom"><div><!-- --></div></div>
                      
                <h3>
                    <asp:Literal ID="Literal11" runat="server" Text="<%$Resources:Tags %>"></asp:Literal>
                </h3>
                <fieldset class="set">
                    <ol class="setIn">
                        <li class="tags">
                          <sf:ContentTagEditor ID="tagsControl" runat="server" />
                        </li>
                    </ol>
                </fieldset>
                <div class="bottom"><div><!-- --></div></div>
                  
                <h3>
                    <asp:Literal ID="Literal12" runat="server" Text="<%$Resources:AdditionalInfo %>"></asp:Literal>
                </h3>
                <fieldset class="set">
                    <div class="setIn">
                        <p class="example">
                            <asp:Literal ID="Literal13" runat="server" Text="<%$Resources:AdditionalInfoNote %>"></asp:Literal>
                        </p>
                        <ol>
                            <li>
                                <asp:label id="lblRanking" associatedcontrolid="Ranking" runat="server">
                                    <asp:literal id="ltrRanking" runat="server" text="<%$Resources:Ranking %>"></asp:literal>
                                    <em id="RankingLabel" runat="server"></em></asp:label>
                                <asp:textbox maxlength="250" id="Ranking" runat="server"></asp:textbox>
                            </li>
                            <li class="selector">
                                <asp:label id="lblLinkTo" associatedcontrolid="LinkTo" runat="server"><asp:literal id="ltrLinkTo" runat="server" text="<%$Resources:LinkTo %>"></asp:literal><em id="LinkToLabel" runat="server"></em></asp:label>
                                <asp:textbox maxlength="250" id="LinkTo" runat="server"></asp:textbox>
                                <sflib:buttonselector runat="server" id="selectFromExistingLink" buttontext="<%$Resources:Select %>" windownavigateurl="~/Sitefinity/UserControls/Dialogs/PagesSelector.aspx" itemtemplatepath="~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/ButtonSelector.ascx" associatedcontrols="LinkTo" cssclass="pickerWrapper" />
                            </li>
                            <li>
                                <asp:Label ID="lblSummary" AssociatedControlID="Summary" runat="server"><asp:Literal ID="ltrSummary" runat="server" Text="<%$Resources:Summary %>"></asp:Literal> <em id="SummaryLabel" runat="server"></em></asp:Label>
                                <asp:TextBox MaxLength="250" ID="Summary" TextMode="MultiLine" Text="" runat="server"></asp:TextBox>
                                <p class="example"><asp:Literal ID="ltrSummaryNote" runat="server" Text="<%$Resources:SummaryNote %>"></asp:Literal></p>
                            </li
                        </ol>
                    </div>
                </fieldset
                <div class="bottom"><div><!-- --></div></div>
                  
                <h3>
                    <asp:Literal ID="ltrPictures" runat="server" Text="<%$Resources:Pictures %>"></asp:Literal>
                </h3>
                <fieldset class="set">
                    <div class="setIn">
                        <p class="example">
                            <asp:Literal ID="ltrPicturesNote" runat="server" Text="<%$Resources:PicturesNote %>"></asp:Literal>
                        </p>
                        <ol>
                            <li>
                                <asp:Label ID="lblRankingGallery" AssociatedControlID="Gallery" runat="server"><asp:literal ID="ltrRankingGallery" runat="server" Text="<%$Resources:RankingGallery %>"></asp:literal> <em id="RankingGalleryLabel" runat="server"></em></asp:Label>
                                <econtrols:GalleryPicker ID="Gallery" runat="server" />
                            </li>
                            <li class="selector">
                                <asp:Label ID="lblRankingPicture" AssociatedControlID="Picture" runat="server"><asp:literal ID="ltrRankingPicture" runat="server" Text="<%$Resources:RankingPicture %>"></asp:literal> <em id="AltRankingPicture" runat="server"></em></asp:Label>
                                <asp:TextBox MaxLength="250" ID="Picture" runat="server"></asp:TextBox>
                                <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="Picture" runat="server" cssclass="pickerWrapper" ButtonText="<%$Resources:Select%>" />
                            </li>
                            <li class="selector">
                                <asp:Label ID="lblRankingThumb" AssociatedControlID="Thumb" runat="server"><asp:literal ID="ltrRankingThumb" runat="server" Text="<%$Resources:RankingThumb %>"></asp:literal> <em id="AltRankingThumbLabel" runat="server"></em></asp:Label>
                                <asp:TextBox MaxLength="250" ID="Thumb" runat="server"></asp:TextBox>
                                <sfLib:ButtonSelector WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageEditorDialog.aspx" ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" AssociatedControls="Thumb" runat="server" cssclass="pickerWrapper" ButtonText="<%$Resources:Select%>" />
                            </li>
                        </ol>
                    </div>
                </fieldset>
                <div class="bottom"><div><!-- --></div></div>
                  
                    <h3><asp:Literal ID="Literal24" runat="server" Text="<%$Resources:Schedule %>"></asp:Literal></h3>
                    <fieldset class="set dates">
                        <ol class="setIn">                               
                          
                         <li>
                            <asp:Label ID="Label6" AssociatedControlID="Publication_Date" runat="server"><asp:Literal ID="Literal25" runat="server" Text="<%$Resources:PublicationDate %>"></asp:Literal> <em id="Publication_DateLabel" runat="server"></em></asp:Label>                                    
                            <telerik:RadDateTimePicker ID="Publication_Date" runat="server"></telerik:RadDateTimePicker>
                        </li>
                        <li>
                            <asp:Label ID="Label7" AssociatedControlID="Expiration_Date" runat="server"><asp:Literal ID="Literal26" runat="server" Text="<%$Resources:ExpirationDate %>"></asp:Literal> <em id="Expiration_DateLabel" runat="server"></em></asp:Label>                                    
                            <telerik:RadDateTimePicker ID="Expiration_Date" runat="server"></telerik:RadDateTimePicker>
                        </li>                                 
                    </ol>
                </fieldset>
            </ItemTemplate>
        </sf:ContentMetaFields>
        <div class="bottom bot">
            <div>
                <!-- -->
            </div>
        </div>
          
        <p class="button_area bot">
            <asp:LinkButton ID="saveButton2" runat="server" CssClass="CmsButLeft okdark">
                <asp:Literal ID="Literal16" runat="server" Text="<%$Resources:SaveChanges %>" />
            </asp:LinkButton>
            <asp:Label ID="Literal17" runat="server" Text="<%$Resources:Or %>" />
            <asp:LinkButton ID="cancelButton2" Text="<%$Resources:Cancel %>" runat="server" CssClass="cmscclcmd" CausesValidation="false" />
        </p>
    </div>
    <div class="info" id="divEditFaq" runat="server">
        <div class="infoBottom">
            <h3>
                <asp:Literal ID="Literal19" runat="server" Text="<%$Resources:RankingsFAQ %>"></asp:Literal></h3>
            <asp:Literal ID="Literal20" runat="server" Text="<%$Resources:RankingsFAQText %>"></asp:Literal>
            <p class="hideAllFAQs">
                <a href="javascript:void(0)" onclick="javascript:Rankingalization.hideFaqSection('<%= divEditFaq.ClientID %>')">
                    Hide FAQs everywhere</a>
            </p>
        </div>
    </div>
    <div class="clear">
        <!-- -->
    </div>
    </div>

    using System;
    using Telerik.Cms.Engine.WebControls.Admin;
    using Telerik.DataAccess.AspnetProviders;
      
    namespace Estate.SitefinityModules.Rankings.WebControls.Admin.Rankings
    {
        /// <summary>
        /// View for editing rankings
        /// </summary>
        public class RankingEditView : ContentItemEdit<RankingsView>
        {
            #region View layout and template
      
            /// <summary>
            /// Gets or sets the path to a custom layout template for the control.
            /// </summary>
            /// <value></value>
            [WebSysTemplate(RankingEditView.layoutTemplateName, "RankingEditView_Template_Desc", "/Rankings", false, "2009-04-10")]
            public override string LayoutTemplatePath
            {
                get
                {
                    return base.LayoutTemplatePath;
                }
                set
                {
                    base.LayoutTemplatePath = value;
                }
            }
      
            /// <summary>
            /// Gets the name of the embedded layout template. This property must be overridden to provide the path (key) to an embedded resource file.
            /// </summary>
            /// <value></value>
            protected override string LayoutTemplateName
            {
                get
                {
                    return RankingEditView.layoutTemplateName;
                }
            }
      
            private const string layoutTemplateName =
                "Estate.SitefinityModules.Rankings.Resources.ControlTemplates.Backend.RankingEditView.ascx";
      
            #endregion
      
            #region Command overrides
      
            /* by overrideing the commands we can make the base module behave differently, while
             * keeping all of its base functionality */
      
            /// <summary>
            /// Gets the history command.
            /// </summary>
            /// <param name="itemId">The item id.</param>
            /// <returns></returns>
            protected override string GetHistoryCommand(Guid itemId)
            {
                return CreateHostViewCommand<RankingHistoryView>(itemId.ToString());
            }
      
            /// <summary>
            /// Gets the list command.
            /// </summary>
            /// <returns></returns>
            protected override string GetListCommand()
            {
                return CreateHostViewCommand<RankingsItemListView>();
            }
      
            /// <summary> 
            /// Gets the preview command.
            /// </summary>
            /// <param name="itemId">The item id.</param>
            /// <returns></returns>
            protected override string GetPreviewCommand(Guid itemId)
            {
                return CreateHostViewCommand<RankingPreviewView>(itemId.ToString());
            }
              
            #endregion
      
            #region Security overrides
      
            /* by overriding the permissions methods, we can substitute the permissions for generic content
             * module with permissions for rankings module, while we leave the base class to perform the
             * business logic based on these permissions */
      
            /// <summary>
            /// Checks the permission.
            /// </summary>
            /// <param name="contentOwnerId">The content owner id.</param>
            /// <param name="requestRights">The request rights.</param>
            /// <returns></returns>
            public override bool CheckPermission(Guid contentOwnerId, int requestRights)
            {
                return this.Host.RankingsManager.GetPermission(contentOwnerId, requestRights).CheckDemand();
            }
      
            /// <summary>
            /// Checks the permission.
            /// </summary>
            /// <param name="right">The right.</param>
            /// <param name="currState">State of the curr.</param>
            /// <returns></returns>
            protected override bool CheckPermission(int right, Telerik.Cms.Engine.IContent currState)
            {
                return this.Host.RankingsManager.GetPermission(currState, right).CheckDemand();
            }
      
            /// <summary>
            /// Demands the permission.
            /// </summary>
            /// <param name="right">The right.</param>
            protected override void DemandPermission(int right)
            {
                this.Host.RankingsManager.GetPermission(right).Demand();
            }
      
            /// <summary>
            /// Demands the permission.
            /// </summary>
            /// <param name="right">The right.</param>
            /// <param name="currState">State of the curr.</param>
            protected override void DemandPermission(int right, Telerik.Cms.Engine.IContent currState)
            {
                this.Host.RankingsManager.GetPermission(currState, right).Demand();
            }
      
            #endregion
        }
    }
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    05 Mar 2010
    Link to this post
    Hi David van Geel,

    The module is basic and everything looks fine for me. I saw that you have the following references in the head

    <%@ Register Assembly="App_Code" Namespace="RandomSFCode.MetaMaster2008" TagPrefix="cc1" %>
    <%@ Register TagPrefix="econtrols" Src="~/Estate/UserControls/Admin/GalleryPicker.ascx" TagName="GalleryPicker" %>
    <%@ Register TagPrefix="econtrols" Src="~/Estate/UserControls/Admin/ListPicker.ascx" TagName="ListPicker" %>

    but they are not used ( except GalleyPicker) so if you use them to set any value make sure that there is not some kind of interaction with your custom metakey. You can temporarily remove some of the controls to see whether you will keep getting the error.

    Have you checked the code I sent you and type the same value you are entering in Rating Textbox. Check what is set to "data". If the value is not correct the code snippet should thrown the same error as when you are saving a content item.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Hanadi
    Hanadi avatar
    6 posts
    Registered:
    17 Jan 2008
    10 May 2010
    Link to this post
    I also have a need to use a meta key of valueType Integer.
    The value will not save in the admin section. 
    How and where do I need to do the ValueType conversion?

    Thanks.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    10 May 2010
    Link to this post
    Hello Hanadi,

    It depends on for which module you want to use this metadata. All metakeys are declared in the web.config for a given provider under <metaFields> section. Note that if you have already a given metakey and change its valueType, this type will apply only to the items that will be created after the type modification.

    You could take a look at our UserManual - page 214 Adding Custom Fields.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Hanadi
    Hanadi avatar
    6 posts
    Registered:
    17 Jan 2008
    11 May 2010
    Link to this post
    Yes, this a custom module with lots of meta keys of type ShortText which work fine. When I tried to add a meta key of type Integer it errors out in the edit template <ModuleName>EditView.ascx because the tag sf:ContentMetaFields cannot automatically save the text from a TextBox into an Integer meta key.

    So, how do I perform the conversion to save the value as Integer? I can't use ShortText for this particular meta key as I need to do GreaterThan, lessThan comparisons on it.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 May 2010
    Link to this post
    Hi Hanadi,

    ContentMetaFields has support for Integer value types. The integer value should be automatically persisted and then retrieved. You could take a look at the attached video. Please check your code.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  11. Hanadi
    Hanadi avatar
    6 posts
    Registered:
    17 Jan 2008
    12 May 2010
    Link to this post
    Thanks, that video is cool.
    Yes, Integer meta keys work. I had switched existing content items from ShortText to Integer.
    I had to run the sql update to change the meta type and values in the table. Everything works now.
    Adding or changing meta keys on existing items is troublesome.



Register for webinar
11 posts, 0 answered