Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Graham Carr 277 posts 389 karma points
    Sep 01, 2014 @ 11:21
    Graham Carr
    0

    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:

    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??

     

  • Graham Carr 277 posts 389 karma points
    Sep 01, 2014 @ 11:27
    Graham Carr
    0

    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>

  • Danny Blatant 91 posts 358 karma points
    Sep 09, 2014 @ 12:59
    Danny Blatant
    0

    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"

  • Graham Carr 277 posts 389 karma points
    Sep 09, 2014 @ 13:09
    Graham Carr
    0

    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

     

  • Danny Blatant 91 posts 358 karma points
    Sep 09, 2014 @ 13:15
    Danny Blatant
    0

    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"

  • Mark 49 posts 130 karma points
    Dec 10, 2014 @ 10:26
    Mark
    0

    Hey, yeah sorry just add "Models" to the namespace in the web.config under "views".

    cheers

Please Sign in or register to post replies

Write your reply to:

Draft