Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Good question, there is no inbuilt support as the <code>View()</code> method expects a string, but there is a Nifty tool called <a href="http://mvccontrib.codeplex.com/wikipage?title=T4MVC_doc&amp;referringTitle=T4MVC" rel="nofollow noreferrer">T4MVC</a> created by <a href="https://stackoverflow.com/users/111888/david-ebbo">David Ebbo</a> that does just that.</p> <p>The documentation on codeplex has a manual install procedure, I would recommend getting it with NuGet package manager straight from VS2010.</p> <p>Its pretty simple, the whole thing is files which you can just add to your project. (<code>T4MVC.tt</code> and <code>T4MVC.settings.t4</code>), everytime you change your code, <strong>(1)</strong> Right-click T4MVC.tt and <strong>(2)</strong> Click <em>"Run Custom Tool"</em>.</p> <p>What it does is generate a class with Subclasses, Members, Properties for all your Controllers and Views. What it even does is create strong types for all your content, like images, css, js etc. (Which I think is just awesome)</p> <p>Examples:<br> <strong>This</strong></p> <pre><code>@Html.RenderPartial("DinnerForm"); </code></pre> <p>Would be:</p> <pre><code>@Html.RenderPartial(MVC.Dinners.Views.DinnerForm); </code></pre> <p><strong>This:</strong></p> <pre><code>@Html.ActionLink("Delete Dinner", "Delete", "Dinners", new { id = Model.DinnerID }, null) </code></pre> <p>Would Be this instead:</p> <pre><code>@Html.ActionLink("Delete Dinner", MVC.Dinners.Delete(Model.DinnerID)) </code></pre> <p><strong>This :</strong></p> <pre><code>&lt;img src="/Content/nerd.jpg" /&gt; </code></pre> <p>Would be this instead:</p> <pre><code>&lt;img src="@Links.Content.nerd_jpg" /&gt; </code></pre> <p>You do have to Right-Click on the <code>tt</code> file and "Run Custom Tool" as mentioned before every time you change your views, controllers, however, if you want to automate this, <a href="http://blogs.msdn.com/b/davidebb/archive/2010/07/17/check-out-chirpy-a-very-cool-add-in-to-run-t4mvc-and-do-many-other-cool-things.aspx" rel="nofollow noreferrer">Check out Chirpy</a> which does that and more.</p> <p>(<strong>Note</strong> T4MVC has aspx/mvc2 examples on the docs but works fine on MVC3 as I use in production with a MVC3/Razor app)</p> <p>Also see <a href="https://stackoverflow.com/tags/t4mvc">T4MVC tag</a> on SO.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload