This is exactly the same page I linked, only the url is a bit different. :D
The example on the bottom page is for v6 of umbraco (Sample razor script (DynamicNode, pre umbraco 6.0.0)).
So let's say I create the comment form delivered with umbraco forms. I render this form on my template and then create a partial view with the code from the docupage we linked.
I get the following error:
2015-08-20 09:00:45,003 [10] ERROR Umbraco.Core.UmbracoApplicationBase - [P4172/T1/D2] An unhandled exception occurred
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'Id'
2015-08-20 14:27:08,281 [50] ERROR Umbraco.Core.UmbracoApplicationBase - [P4172/T134/D3] An unhandled exception occurred
System.Web.HttpCompileException (0x80004005): c:\~~~~\Views\Partials\ListApprovedComments.cshtml(4): error CS0103: Der Name 'Library' ist im aktuellen Kontext nicht vorhanden.
2015-08-20 14:40:43,175 [50] ERROR Umbraco.Core.UmbracoApplicationBase - [P4172/T134/D3] An unhandled exception occurred
System.Web.HttpCompileException (0x80004005): c:\~~~\Views\Partials\ListApprovedComments.cshtml(6): error CS1928: 'Umbraco.Forms.Mvc.DynamicObjects.DynamicRecordList' enthält keine Definition für 'OrderBy', und die Überladung der optimalen Erweiterungsmethode 'Umbraco.Web.PublishedContentExtensions.OrderBy(System.Collections.Generic.IEnumerable<Umbraco.Core.Models.IPublishedContent>, string)' weist einige ungültige Argumente auf.
bei System.Web.Compilation.AssemblyBuilder.Compile()
I guess you also have to add @using System.Linq.
Those using statements can also be "centralized" for all your views if you add them to the namespaces list in the ~\Views\web.config file.
System.Web.HttpCompileException (0x80004005): ___\Views\Partials\ListApprovedComments.cshtml(12): error CS1928: 'Umbraco.Forms.Mvc.DynamicObjects.DynamicRecordList' enthält keine Definition für 'OrderBy', und die Überladung der optimalen Erweiterungsmethode 'Umbraco.Web.PublishedContentExtensions.OrderBy(System.Collections.Generic.IEnumerable<Umbraco.Core.Models.IPublishedContent>, string)' weist einige ungültige Argumente auf.
List of approved comments from umbraco.forms
Hey,
I tried to set up a comment form with umbraco.forms but I can't find a way to list all approved records on my side.
Only thing I found was this documentation: https://our.umbraco.org/documentation/Add-ons/UmbracoForms/Developer/Working-With-Data/
The example on that site is for umbraco v6, so it didn't help me.
Can someone help me with that?
This version of the docs should be fairly up-to-date.
https://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Working-with-Contour-data-in-Razor/
This is exactly the same page I linked, only the url is a bit different. :D The example on the bottom page is for v6 of umbraco (Sample razor script (DynamicNode, pre umbraco 6.0.0)).
Sorry, I didn't try it, but I know it's in the Umbraco 7 version too. The example is still valid, disregard the "pre 6.0" stuff. :)
So let's say I create the comment form delivered with umbraco forms. I render this form on my template and then create a partial view with the code from the docupage we linked. I get the following error:
2015-08-20 09:00:45,003 [10] ERROR Umbraco.Core.UmbracoApplicationBase - [P4172/T1/D2] An unhandled exception occurred Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'Id'
Right, there's this one incompatibility in the sample. :/
This should work:
Then I'll get the following error:
2015-08-20 14:27:08,281 [50] ERROR Umbraco.Core.UmbracoApplicationBase - [P4172/T134/D3] An unhandled exception occurred System.Web.HttpCompileException (0x80004005): c:\~~~~\Views\Partials\ListApprovedComments.cshtml(4): error CS0103: Der Name 'Library' ist im aktuellen Kontext nicht vorhanden.
Did you add
to the top of Your view?
Nope, didn't had that on my view, but added it. Know my view looks like this:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Umbraco.Forms.Mvc.DynamicObjects;
And get the following error:
I guess you also have to add
@using System.Linq
.Those using statements can also be "centralized" for all your views if you add them to the namespaces list in the ~\Views\web.config file.
Hey Lars,
sadly the error is still the same.
Right,
Not sure whether there's an extension that takes strings for ordering, but you can use lambda expressions for the
DynamicRecord
.Like so:
Still get a error:
Try
So if I remove all variables except for
It loads, but I won't get the value for @record.Name.
My fields are calles "Email", "Name" and "Comment", how to I get the value of those fields?
Thanks so far Lukas!
Might be using the typed version (
DynamicRecord
) actually disables the dynamic-ness.Try using the
GetField
method:@record.GetField("Name").ValuesAsString()
,@record.GetField("Email").ValuesAsString()
etc.Thanks, now it works as intended by me!
Glad you finally got it working. :)
is working on a reply...