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 826 posts 1269 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

     

  • Comment author was deleted

    Jan 28, 2013 @ 13:59

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

  • Martin Griffiths 826 posts 1269 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? :-)

  • Comment author was deleted

    Jan 28, 2013 @ 14:09

    vs 2010 or vs2012 ?

  • Martin Griffiths 826 posts 1269 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! :-)

  • Comment author was deleted

    Jan 28, 2013 @ 14:27

    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

  • Comment author was deleted

    Jan 28, 2013 @ 14:30

    Maybe try changing

    @inherits Umbraco.Forms.Mvc.Models.FieldViewModel

    to

    @inherits WebViewPage<Umbraco.Forms.Mvc.Models.FieldViewModel>
    in your example above  
  • Martin Griffiths 826 posts 1269 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

  • Comment author was deleted

    Jan 29, 2013 @ 09:44

    Perfect :)

Please Sign in or register to post replies

Write your reply to:

Draft