Copied to clipboard

Flag this post as spam?

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


  • Martin Griffiths 791 posts 1189 karma points c-trib
    Jan 28, 2013 @ 11:39
    Martin Griffiths
    0

    Using contour in an MVC Visual Studio project

    Hi Tim

    I'm trying to use contour in an MVC project in visual studio in an attempt to retain as much intellisense goodness as possible.

    Is this achievable when creating custom field and form views? I've created a standard MVC 3 project and modified the web.configs to use referenece the macroEngines library. 

    But when I create the folllowing...

    @inherits Umbraco.Forms.Mvc.Models.FieldViewModel
    @model Umbraco.Forms.Mvc.Models.FieldViewModel
    <input type="text" name="@Model.Name" id="@Model.Id" class="text" value="@Model.Value" maxlength="@Model.AdditionalSettings.First(s => s.Key == "maxLength").Value" 
    @{if(Model.Mandatory || Model.Validate){<text>data-val="true"</text>}}
    @{if (Model.Mandatory) {<text> data-val-required="@Model.RequiredErrorMessage"</text>}}
    @{if (Model.Validate) {<text> data-val-regex="@Model.InvalidErrorMessage" data-regex="@Model.Regex"</text>}}

    model does not exist in the current context.

    I've also added Umbraco.Forms.Mvc as a reference. Along with the usual core umbraco and contour libraries.

    Any ideas?

    Martin

     

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 28, 2013 @ 13:59
    Tim Geyssens
    0

    Hmm not sure what exaclty is needed for that, maybe google knows ;) will give it a test myself

  • Martin Griffiths 791 posts 1189 karma points c-trib
    Jan 28, 2013 @ 14:07
    Martin Griffiths
    0

    If you manage to get the project working, can you send it to me? :-)

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 28, 2013 @ 14:09
    Tim Geyssens
    0

    vs 2010 or vs2012 ?

  • Martin Griffiths 791 posts 1189 karma points c-trib
    Jan 28, 2013 @ 14:10
    Martin Griffiths
    0

    We are moving over to 2012 now, so 2012 if you have it. 2010 if you dont! :-)

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 28, 2013 @ 14:27
    Tim Geyssens
    1

    Got it working vs2012 https://dl.dropbox.com/u/886345/TestIntellisense.zip

    @inherits WebViewPage<FieldViewModel>     
    @model FieldViewModel

    It's the inherits that does the trick

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 28, 2013 @ 14:30
    Tim Geyssens
    1

    Maybe try changing

    @inherits Umbraco.Forms.Mvc.Models.FieldViewModel

    to

    @inherits WebViewPage<Umbraco.Forms.Mvc.Models.FieldViewModel>
    in your example above  
  • Martin Griffiths 791 posts 1189 karma points c-trib
    Jan 29, 2013 @ 09:39
    Martin Griffiths
    0

    Hi Tim

    I used your project as an example to copy over the necessary references and config and all working now.

    Many thanks

    Martin

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Jan 29, 2013 @ 09:44
    Tim Geyssens
    1

    Perfect :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies