Copied to clipboard

Flag this post as spam?

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


  • jeff mayer 122 posts 200 karma points
    Jun 26, 2014 @ 16:49
    jeff mayer
    0

    Error Getting MNTP info

    Using 7.14. I am trying to get basic information from a MNTP datatype but am getting this error when using the following code which is based on the u7 Docs. Any suggestions?

    @{

        if (Model.Content.HasValue("resourcespicker"))

        {

            var docListValue = Model.Content.GetPropertyValue<string>("resourcespicker");

            var docList = docListValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);

            var docCollection = Umbraco.TypedContent(docList).Where(x => x != null);

            foreach (var item in docCollection)

            {

                <p>@item.Name</p>

            }

        }

    }  

     

     

     

    Error below:

     

    [Thread 50] Error loading partial view macro (View: ~/Views/MacroPartials/GetDocsMedia.cshtml). Exception: System.FormatException: Input string was not in a correct format.

       at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)

       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)

       at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)

       at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()

       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()

       at ASP._Page_Views_MacroPartials_GetDocsMedia_cshtml.Execute() in c:\inetpub\dev\website.com\Views\MacroPartials\GetDocsMedia.cshtml:line 34

       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()

       at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()

       at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)

       at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)

       at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult)

       at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content)

       at umbraco.macro.LoadPartialViewMacro(MacroModel macro)

       at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

  • jeff mayer 122 posts 200 karma points
    Jun 26, 2014 @ 17:04
    jeff mayer
    0

    I think I have it figured out now. I am using Jeavon's excellent Property Value converter defined here.

    https://github.com/Jeavon/Umbraco-Core-Property-Value-Converters/blob/v2/Docs/MultiNodeTreePicker.md

    Using his code sample it works

     @{
            var typedMultiNodeTreePicker = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("resourcespicker");
            foreach (var item in typedMultiNodeTreePicker)
            {
                <p>@item.Name</p>
            }
        }
    
  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 26, 2014 @ 18:45
    Jeavon Leopold
    0

    Hi Jeff,

    Yes, if you have my converters installed you need to use the snippets in my documentation for those editors instead of the standard snippets in the Umbraco documentation.

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft