In a partial view, I am listing documents within a foreach loop.
However, I am parsing the values and making some alterations via some classes in a @functions{ section.
Within the @functions{ section I can't seem to be able to use
Umbraco.TypedMedia
in a class eg
public class rowOutput{
...
private string fetchPropertyValue(
...
int mediaId = Int32.Parse(pValue);
var media = Umbraco.TypedMedia(mediaId);
pValue = media.Url;
returns error
CS0038: Cannot access a non-static member of outer type 'Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Web.Models.RenderModel>' via nested type 'ASP._Page_Views_Partials_Listings_GenericSearch_cshtml.rowOutput'
I'm hazy as to that this error means. Is there any way round this?
This problem with inheriting in master and your view, or maybe some custom logic in controllers.
Do you have the same inherits attribute in your views?
Error using Umbraco.TypedMedia in @functions
In a partial view, I am listing documents within a foreach loop.
However, I am parsing the values and making some alterations via some classes in a @functions{ section.
Within the @functions{ section I can't seem to be able to use
in a class eg
returns error
I'm hazy as to that this error means. Is there any way round this?
Hi Tim,
What about '@inherit' attribute of your view? Can you show? Do you use some custom serverside controller?
Thanks
It's not a custom controlled just a standard partial view.
This problem with inheriting in master and your view, or maybe some custom logic in controllers. Do you have the same inherits attribute in your views?
Do you mean the template : I am not working in Visual Studio, these are just templates and partial views in the Umbraco backoffice.
Yes, can you show all your view ?
Inherited from master...
Not clear what the problem. It's typical error when rendering with wrong inherits attribute.
What if I tried putting some c# in app_code to do the conversion from media id to media url : what namespaces would I need?
You need Umbraco context helper.
Are you using static class?
Managed to find a work around by adding code to App_Code
is working on a reply...