section which tries to use Umbraco.Helper to get the url of a media image given its id. ie.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
...
@functions{
public class rowOutput{
...
int mediaId = Int32.Parse(pValue);
umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current); pValue = umbracoHelper.TypedMedia(mediaId).Url.ToString();
...
}
...
}
but I get this error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'umbracoHelper' does not exist in the current context
Source Error:
Line 641: int mediaId = Int32.Parse(pValue);
Line 642: umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
Line 643: pValue = umbracoHelper.TypedMedia(mediaId).Url.ToString();
How can I add reference to Umbraco.Helper in this partial view?
I think this is just because the umbracoHelper variable isn't declared in your function eg:
int mediaId = Int32.Parse(pValue);
var umbracoHelper = new
Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
pValue = umbracoHelper.TypedMedia(mediaId).Url.ToString();
But equally you can access the UmbracoHelper from the property on the partial view eg:
int mediaId = Int32.Parse(pValue);
pValue = Umbraco.TypedMedia(mediaId).Url.ToString();
Would have the same result, but not involve creating a new helper...
Using Umbraco.helper in a partial view @functions
In a prtial view, I have some code in an
section which tries to use Umbraco.Helper to get the url of a media image given its id. ie.
but I get this error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'umbracoHelper' does not exist in the current context
Source Error:
Line 641: int mediaId = Int32.Parse(pValue); Line 642: umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
Line 643: pValue = umbracoHelper.TypedMedia(mediaId).Url.ToString();
How can I add reference to Umbraco.Helper in this partial view?
Many thanks
Hi Tim C
I think this is just because the umbracoHelper variable isn't declared in your function eg:
But equally you can access the UmbracoHelper from the property on the partial view eg:
Would have the same result, but not involve creating a new helper...
regards
marc
is working on a reply...