I am trying to use the UrlPicker, however it doesn't seem to recognise the UrlPicker property, the following gives a CS0246: The type or namespace name 'UrlPicker' could not be found (are you missing a using directive or an assembly reference?) error:
var twitter = Model.Content.As<UrlPicker>("twitterAccount");
What namespace/using statement should be used within the top of the CSHTML file with the above code in to allow UrlPicker to be identified??
I have found out what needs to be added, ensure you add the following to the top of your namepsace file, as an example:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Models @using Umbraco.Web.Routing @{ Layout = null; var twitter = Model.Content.As<UrlPicker>("twitterAccount"); var youTube = Model.Content.As<UrlPicker>("youtubeAccount"); }
<li><a href="@(twitter.IsInternal ? Umbraco.Url(twitter.InternalLink, UrlProviderMode.Relative) : twitter.ExternalUrl)" title="Follow us on Twitter" target="_blank"><img src="/images/twitter-icon.png" alt="Follow us on Twitter" width="44" height="44" /></a></li>
I have the same issue, however the snippet above does not work for me. It does not recognise 'Models' (The type or namespace 'Models' could not be found (are you missing a using directive or an assembly reference?)"...
Any more advise? I tried using :
@using UrlPicker.Umbraco.Models (which is a valid namespace path, or at least intellisense sees this path) but in this case it complains about the 'Umbraco' with the error "The type name 'Umbraco' does not exist in the dtype 'UrlPicker.Umbraco.Models.UrlPicker'
I have no idea what the problem is here (I am using Umbraco 7, dotNET4.5, mvc and razor), perhaps this is a conflict with the Umbraco namespace??
The namespace Models refers to the Models folder of the App_Code directory within your Umbraco solution. This should have been created when you installed the Package. For your reference my App_Code folder is as follows:
@{ var test = new UrlPicker.Umbraco.Models.UrlPicker(); }
However with some testing, it transpires that both code blocks above work! It seems it is a confusion inthe intellisense of my editor as both code versions worked 100% with a clean rebuild.
Namespace
I am trying to use the UrlPicker, however it doesn't seem to recognise the UrlPicker property, the following gives a CS0246: The type or namespace name 'UrlPicker' could not be found (are you missing a using directive or an assembly reference?) error:
What namespace/using statement should be used within the top of the CSHTML file with the above code in to allow UrlPicker to be identified??
I have found out what needs to be added, ensure you add the following to the top of your namepsace file, as an example:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Models
@using Umbraco.Web.Routing
@{
Layout = null;
var twitter = Model.Content.As<UrlPicker>("twitterAccount");
var youTube = Model.Content.As<UrlPicker>("youtubeAccount");
}
<li><a href="@(twitter.IsInternal ? Umbraco.Url(twitter.InternalLink, UrlProviderMode.Relative) : twitter.ExternalUrl)" title="Follow us on Twitter" target="_blank"><img src="/images/twitter-icon.png" alt="Follow us on Twitter" width="44" height="44" /></a></li>
Hi,
I have the same issue, however the snippet above does not work for me. It does not recognise 'Models' (The type or namespace 'Models' could not be found (are you missing a using directive or an assembly reference?)"...
Any more advise? I tried using :
@using UrlPicker.Umbraco.Models (which is a valid namespace path, or at least intellisense sees this path) but in this case it complains about the 'Umbraco' with the error "The type name 'Umbraco' does not exist in the dtype 'UrlPicker.Umbraco.Models.UrlPicker'
I have no idea what the problem is here (I am using Umbraco 7, dotNET4.5, mvc and razor), perhaps this is a conflict with the Umbraco namespace??
Thanks in advance
Danny "Blatant"
The namespace Models refers to the Models folder of the App_Code directory within your Umbraco solution. This should have been created when you installed the Package. For your reference my App_Code folder is as follows:
App_Code
- Models
- PropertyEditors
- CallToAction.cs
- OpenGraphTag.cs
- UrlPicker.cs
Hi Graham,
Thanks for the info, howeve to elaborate on the issue, which I think I think is a false posative within intellisense.
By example, the following code highlights 'Umbraco' on the 2 UrlPicker using lines as "The type name does not exist" :
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Umbraco.Web.Routing
@using UrlPicker
@using UrlPicker.Umbraco
@using UrlPicker.Umbraco.Models
@{
var test = new UrlPicker();
}
Whereas this code works fine in the editor :
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Umbraco.Web.Routing
@{
var test = new UrlPicker.Umbraco.Models.UrlPicker();
}
However with some testing, it transpires that both code blocks above work! It seems it is a confusion inthe intellisense of my editor as both code versions worked 100% with a clean rebuild.
Thanks,
Danny "Blatant"
Hey, yeah sorry just add "Models" to the namespace in the web.config under "views".
cheers
is working on a reply...