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)
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.
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).
Any tips on how I can get around this?
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.
Try:
This will improve in 4.7.1 by the way, with a better HasValue method.
is working on a reply...