Copied to clipboard

Flag this post as spam?

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


  • Pedro Graca 1 post 21 karma points
    Jul 16, 2015 @ 09:43
    Pedro Graca
    0

    VS2013 Intellisense not working on views

    Hi everyone,

    Hopefully someone can give me a hand. I am trying to move away from webforms in umbraco 7 into MVC but I'm off to a bad start.

    I'll explain step by step what I have done and hopefully someone can correct me if I made any mistakes...

    • Downloaded the latest version of umbraco 7
    • Copied all the files to a folder
    • Opened VS2013
    • File/open/Web Site

    Ran the code and completed all the configuration steps and everything is running fine (installed a sample template to get my head around the MVC), however...

    Pulled up the Home.cshtml from the Views folder in VS2013

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "Master.cshtml";
    }
    
    @CurrentPage.GetGridHtml("content", "fanoe")
    

    When I type @CurrentPage and press the '.' nothing comes up.

    I've tried to delete the .suo, reset the settings in VS, restarting...nothing.

    Your help will be mostly appreciated.

    Best regards, Pedro

  • Marc Love (uSkinned.net) 447 posts 1789 karma points
    Jul 16, 2015 @ 11:38
    Marc Love (uSkinned.net)
    0

    Hi Pedro,

    You need to use IPublishedContent to get intellisense in VS.

    We normally change our views to inherit from:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<IPublishedContent>
    

    You can then use:

    @Model.GetGridHtml("content", "fanoe")
    

    Cheers,

    Marc

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Jul 16, 2015 @ 14:01
    Steve Morgan
    0

    HI Pedro - is the view file included in the project?

    If you created it in the Umbraco UI then you may have to manually refresh the file list and include it.

  • Ryios 122 posts 263 karma points
    Jul 16, 2015 @ 14:41
    Ryios
    0

    The way you are using visual studio is probably your problem.

    You copied the files to a folder than used File -> Open -> Website. As such your web.config in the views folder could be wrong, or because it's not a web project type it might not trigger intellisense.

    The preferred pattern goes something like this (in my opinion)..

    1. Open Visual Studio
    2. File -> New -> Project
    3. Chose the Web Tab and ASP.Net Web Application
    4. Give the project a name
    5. Give the project a Location
    6. Give the solution a name (if you want it to be different than the project name)
    7. Click OK
    8. You should now be prompted with the New ASP.Net Project Wizard.
    9. Chose Empty and do not check Web Forms, MVC, or Web Api, or Add Unit Tests, Leave it all empty.

    Click OK

    Once the Project is Open, Open the Nuget Package Console

    Tools -> Nuget Package Manager -> Package Manager Console

    This should open in the tabs at the bottom of the IDE. Go to it and you should be at a Prompt with "PM> " prefixing the cursor.

    Make sure the Package source: drop down is set to nuget.org

    Type: "Install-Package UmbracoCms" at the prompt and press enter

    And away it goes,

    This will install Umbraco Into the project and all of it's dependencies, including MVC 4 and Newtonsoft.Json, etc etc.

    -Note

    As Pedro said @CurrentPage won't give you intellisense because it is a Dynamic Object, there is no intellisense on Dynamic Objects.

    Change your view to inherit from

    @inherits UmbracoTemplatePage

    Then you can do @Model.Content.Name @Umbraco.TypedContent.. @Model.Content.ContentType.. etc etc etc and you'll get intellisense.

Please Sign in or register to post replies

Write your reply to:

Draft