Copied to clipboard

Flag this post as spam?

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


  • Harald Ulriksen 207 posts 249 karma points
    May 24, 2011 @ 22:46
    Harald Ulriksen
    0

    Empty MultiNodePicker cause Error Loading Script - input string not in correct format

    I have a page with a  multinodepicker, the problem is that just accessing the property for this picker cause a rather nasty exception if it's empty (i.e. the user has not selected any nodes).

    var maybeDynamicXml = node.selectedMedia;

    Any tips on how I can get around this? 

    Error Loading Razor Script (file: Categories 
    List) 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.WhereSelectArrayIterator`2.MoveNext()
      at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
      at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
      at umbraco.MacroEngines.DynamicNode.ConvertPropertyValueByDataType(Object& result, String name, Guid dataType)
      at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result)
      at CallSite.Target(Closure , CallSite , Object )   at ASP._Page_macroScripts_CategoriesList_cshtml.<>c__DisplayClass7.<productImage>b__6(TextWriter __razor_helper_writer) in c:\sourcecode\B-Sessions\bid\umbraco\macroScripts\CategoriesList.cshtml:line 14
      at System.Web.WebPages.WebPageBase.Write(HelperResult result)   at ASP._Page_macroScripts_CategoriesList_cshtml.Execute() in c:\sourcecode\B-Sessions\bid\umbraco\macroScripts\CategoriesList.cshtml:line 32
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy()   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)

  • Harald Ulriksen 207 posts 249 karma points
    May 24, 2011 @ 22:59
    Harald Ulriksen
    0

    Solved by checking the GetProperty method before accessing the property directly. This error may be related to the document beeing created by the api, not the UI.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    May 24, 2011 @ 23:03
    Sebastiaan Janssen
    0

    Try:

    @if(Model.SelectedMedia.GetType() != typeof(DynamicNull) && !string.IsNullOrWhitespace(Model.SelectedMedia)) {
    var maybeDynamicXml = Model.SelectedMedia; //Do something with it... }

    This will improve in 4.7.1 by the way, with a better HasValue method.

Please Sign in or register to post replies

Write your reply to:

Draft