Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
Been loving the Razor view engine in 4.7, but I was wondering - is there any way to allow "canvas" editing?
I have a particular need for inline editing on a client's site, and would love to use Razor, but at the moment I'm having to use XSLT
<xsl:value-of select="umbraco.library:Item(@id, 'content')" />
In a template or user control, I can use
<umbraco:Item field="content" runat="server" />
Can anyone point me in the right direction for something similar with Razor?
Thanks
Tom
I have never used Canvas editing, so I'm not sure how it works. but if that XSLT works, why not try:
@umbraco.library.Item(Model.Id, "content")
Thanks Sebastian, I will.
Strangely, .Item() does not come up in intellisense in VS2010 (all other methods do), but it must be there! Protected perhaps, or an extension method. Doesn't error on compilation.
I'll post back and resolve once I've confirmed if this works.
Hmm, looks like it's an alias for GetItem() instead. :-)
Hmm, it's not a static method
An object reference is required for the non-static field, method, or property 'umbraco.library.Item(int, string)'
And the following:
@{ var library = new umbraco.library(); } @library.Item(Model.Id, "content")
Renders:
[ [ [ [umbraco:Item nodeId="1512" field="content" ] ] ] ]
and
@umbraco.library.GetItem(Model.Id, "content")
renders nothing.
So, it looks like the page lifecycle is coming into play here. Not sure it's an option, unless anyone has any other ideas?
Thanks in advance,
If the problem is the page lifecycle you should read this topic: http://our.umbraco.org/forum/developers/razor/21722-Set-Razor-macro-parameters-in-code-behind. It might help.
Jeroen
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Canvas and Razor
Hi,
Been loving the Razor view engine in 4.7, but I was wondering - is there any way to allow "canvas" editing?
I have a particular need for inline editing on a client's site, and would love to use Razor, but at the moment I'm having to use XSLT
In a template or user control, I can use
Can anyone point me in the right direction for something similar with Razor?
Thanks
Tom
I have never used Canvas editing, so I'm not sure how it works. but if that XSLT works, why not try:
Thanks Sebastian, I will.
Strangely, .Item() does not come up in intellisense in VS2010 (all other methods do), but it must be there! Protected perhaps, or an extension method. Doesn't error on compilation.
I'll post back and resolve once I've confirmed if this works.
Hmm, looks like it's an alias for GetItem() instead. :-)
Hmm, it's not a static method
An object reference is required for the non-static field, method, or property 'umbraco.library.Item(int, string)'
And the following:
Renders:
and
renders nothing.
So, it looks like the page lifecycle is coming into play here. Not sure it's an option, unless anyone has any other ideas?
Thanks in advance,
Tom
If the problem is the page lifecycle you should read this topic: http://our.umbraco.org/forum/developers/razor/21722-Set-Razor-macro-parameters-in-code-behind. It might help.
Jeroen
is working on a reply...