Copied to clipboard

Flag this post as spam?

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


  • Bunnynut 136 posts 318 karma points
    Jan 19, 2015 @ 09:42
    Bunnynut
    0

    Creating Partial Views and Templates in Umbraco and Visual Studio

    Good morning,

    I have been developing websites with MVC quite some time now but this is the first time using it in conjunction with Umbraco.

    In the old version of Umbraco, around 4.x, the templates you created in Visuals Studio or in Umbraco would also be editable in its counterpart. So when i created a MasterPage, i could either edit it in Visual Studio or in Umbraco and i could see the changes made in Umbraco. But it seems that in Umbraco 7 that is not the case anymore. All the changes i make in Visual Studio are not automatically available in Umbraco.
    Even when i created a partial view in Visual Studio, into /Views/Shared, i get a .Net error message telling me the view cannot be found in /Views/Shared, but its there. I first have to create it in Umbraco before it can find it.

    This is not only weird but very counterproductive, because i like to have all my changes on file as well.
    Am i doing something wrong?

  • Valerie 67 posts 163 karma points
    Jan 19, 2015 @ 11:05
    Valerie
    0

    Hello,

    I create partial views all the time and they just work out of the box... if I make a new Template in Umbraco 7 back end it appears in the project (needs to show all files and then be included).

    When I reference a partial, it looks like @Html.Partial("ViewName") if it lives in Views/Partials folder or Html.Partial("FolderName/ViewName") if it's in a custom folder. No .cshtml extension or anything.  Are you using this syntax?

  • Valerie 67 posts 163 karma points
    Jan 19, 2015 @ 11:19
    Valerie
    0

    Oh, also make sure the script file is in the "MacroPartials" folder.  If you create the script from the back end it should be in the by default: Developer - Scripting Files - Create - make sure "create macro" is checked. Then refresh solution, include the file in your project.

Please Sign in or register to post replies

Write your reply to:

Draft