List toolbar error?

Apr 20, 2016 at 9:13 PM
Simple content list template with a List Toolbar (added from ace editor) and it throws an error:

There was an error while rendering the template: System.Web.HttpCompileException (0x80004005): c:\devsites\Omnetics\Portals\0\2sxc\Content_Bordered.cshtml(3): error CS1061: 'System.Collections.Generic.List<ToSic.SexyContent.Element>' does not contain a definition for 'Toolbar' and no extension method 'Toolbar' accepting a first argument of type 'System.Collections.Generic.List<ToSic.SexyContent.Element>' could be found (are you missing a using directive or an assembly reference?) at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() ....

Here is my template, pretty basic.
<div class="prodbox-container"> <div class="sc-element"> @List.Toolbar </div> @{ int counter = 0; foreach (var e in (List)) { var Content = e.Content; if (counter == 0) { @Html.Raw("<div class=\"prodbox-column\">") } else if (counter > 0 && counter % 4 == 0) { @Html.Raw("</div><div class=\"prodbox-column\">") } <div class="prodbox-cell text-center"><a href="@Content.Link"><img src="@Content.Image?h=100&mode=crop" alt="@Content.Text" /></a> <a href="@Content.Link"><h4>@Content.Text</h4></a> <div class="">@Content.Toolbar</div> </div> counter++; } @Html.Raw("</div>") } </div> Can you point me to an example of how it should be working ? (need better/updated documentation in general, but that's a different subject)

Apr 20, 2016 at 10:34 PM
It's hard to read because the code is all mangled, but I think the List.Toolbar is your issue.

You probably wanted @ListContent.Toolbar
Apr 21, 2016 at 3:26 PM
Different error with @ListContent.Toolbar

There was an error while rendering the template: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at ASP._Page_Portals_0_2sxc_Content__Bordered_cshtml.Execute() in c:\devsites\xxxx\Portals\0\2sxc\Content_Bordered.cshtml:line 6

How's this: Image

In fact, I get an error with using any list presentation fields.
Apr 21, 2016 at 3:33 PM
Here is the order in how I set this up.
  1. create the list content type
  2. Created some data
  3. Built the razor template
  4. Populated with more entries
  5. Created a presentation content type (Header, heading size, description fields)
  6. Updated the View and set the presentation
  7. Add list toolbar to the chtml template
  8. Error
Apr 22, 2016 at 9:32 AM
Two things
  1. I can't see the error message - the image doesn't show
  2. could you give the list-header a demo-item, just to check that
  3. could you just output the type of ListContent - just to see what you get? most templates we create will have a default listcontent (demo-item) so that the preview always looks good, and if you don't have that, you may have to check for null
Apr 25, 2016 at 6:34 PM
Yeah, there is no demo item for the presentation content. Did not read that was required.
Apr 25, 2016 at 6:40 PM
It's only required, if you want to use it default values without doing all the existance-chenking in code :)
Apr 25, 2016 at 7:21 PM
The shortcuts on the side for list presentation always insert @__List.Presentation.__Whatever instead of @__ListContent__.Whatever.

Also, is there documentation on how these list content templates should be setup? It seems like a bit of guesswork on my part and most of the examples on the 2sxc website seem like they are from versions past.
Apr 25, 2016 at 9:21 PM
I didn't get that. What shortcuts? are the snippets in the code-editor wrong?
thx for the infos