Spark T4 templates for ASP.NET MVC - asp.net-mvc

I was just curious if any Spark T4 templates already exist that match/are similar to the out of the box web forms view templates (create, edit, details, etc...). My Google skills didn't lead me to any results.

I've translated the mvc2 templates to spark, feel free to copy:
http://guiftp.free.fr/SparkViewTemplates.rar

T4MVC should work fine with Spark. Here is a related forum thread. That being said, I'm not clear from your initial post that T4MVC is the kind of thing you're looking for.

I meant this part of comment ! if it helps...
# re: T4MVC 2.5.01: added support for Html.RenderAction and Html.Action
#spark_guy: I haven't played extensively with the Spark view engine, but I think that T4MVC should work with it just as well as it works with the aspx view engine. If you hit specific issues, please let me know.
YOu can find all the T4MVC posts at http://blogs.msdn.com/davidebb/archive/tags/T4MVC/, though ideally there would be a single posts that describes it all in one place (I'll try to do this). Note that if you download T4MVC, the readme has good 'getting started' info that tells you what it's all about.

Related

ASP.NET MVC control similar to forms

first let me say, I have started my first ASP.NET MVC (4) application. Before that, I was a forms developer. I love the MVC concept, even though I have not yet fully understood.
In ASP forms times, we could create a control to encapsulate and use it again. I could not figure out yet which element is similar in MVC. I created a Viewed User Control but that hasnt a code-behind file..
Can you give me an example?
Best regards
Patrik
I'm not positive, but perhaps you might be interested in Partial Views. Here is an article on resuable UI Components
Instead of user controls, try razor helpers refer this link for details. http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx
Even though MVC3 is discussed in the blog post, no need to worry. It is not changed in MVC4

Official "How to" for MVC Editor/Display Templates?

I have been using MVC Editor & Display Templates for a while, but have come to realize that there seems to be very little official documentation on MVC Editor/Display Templates (Html.EditorFor() and Html.DisplayFor()). I found the basic MSDN documentation just showing the technical details (which on their own, are not very helpful), but I'm looking more for an official how-to, sort of like this example.
Are Editor/Display Templates more of an afterthought, and not really widely enough used to justify more in-depth official documentation?
Or, am I blind, and what I'm looking for exists, I just haven't found it yet?
Official documentation? Don't know any off hand, but I know there are a ton of examples. In particular, I like Phil Haack's discussion on model binding to lists. It includes an example for an editor template in a pretty complicated example. There's source code there, too.
Since he's co-authored every MVC Wrox book, I consider him a pretty definitive source:
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx
Here's another blog post (non-official) in a similar vein:
http://blogs.msdn.com/b/stuartleeks/archive/2010/03/30/collections-and-asp-net-mvc-templated-helpers-displayfor-editorfor.aspx
best article that I have found for it is:
http://www.growingwiththeweb.com/2012/12/aspnet-mvc-display-and-editor-templates.html
It explains how to create DisplayFor and EditorFor templates really well.
ASP.NET MVC have a lot of materials on http://www.asp.net/mvc with different examples. EditorTemplates and DisplayTemplates is spetial folders for models (like here Quick Tips About ASP.NET MVC – Editor Templates) and you asking about html helpers, not templates.

Upgrading view engine to Razor

I wan't to upgrade my MVC.Net site to 3.0 and also upgrade my asp.net view engine to the Razor.
I have seen that e.g. master pages look a bit different, so are there any tutorials on how to do a switch from asp.net to Razor?
Also how can I update the view engine for an existing site?
I'd also suggest reading the blog posts by ScottGu as they're the best documentation that we've got for Razor.
I can suggest you try this tool for converting the bulk of the views (at least the simple ones):
https://github.com/telerik/razor-converter
But don't get me wrong - the conversion still requires human input and lots of it. Detailed knowledge of the Razor conventions is very much important.
Good luck!
Scott Gu has a good series of blog posts about how Razor layouts work.

ASP.NET MVC web site template

I would like to download ASP.NET MVC web site template. Please guide me where can i find and how i can use. I'm new to this pattern. Thanks in advance.
You can try starting at http://msdn.microsoft.com/en-us/library/dd410597.aspx
it already starts with a little code and design to show you the basics then walks you through a few more things like how controllers work, how a model can be used to simplify dealing with posted values and common content etc.
Here you go!
http://mvccontribgallery.codeplex.com/ - design templates
http://www.asp.net/mvc - look # the sample application section (open source, good tutorials included)
Guys from http://pixelsinspired.com are starting something you may be interested in. There is only one template, but it is free and looks great.

Test Views in ASP.NET MVC2 (ala RSpec)

I am really missing heavily the ability to test Views independently of controllers. The way RSpec does it.
What I want to do is to perform assertions on the rendered view (where no controller is involved!). In order to do so I should provide required Model, ViewData and maybe some details from HttpContextBase (when will we get rid of HttpContext!).
So far I have not found anything that allows doing it. Also it might heavily depend on the ViewEngine being used.
List of things that views might contain are:
Partial views (may be nested deeply).
Master pages (or similar in other view engines).
Html helpers generating links and other elements.
Generally almost anything in a range of common sense :) .
Also please note that I am not talking about client-side testing and thus Selenium is just not related to it at all. It is just plain .NET testing.
So are there any options to actually do the testing of views?
Thanks,
Dmitriy.
The main issue with testing full views is that the asp.net view engine calls Response.Write in the supplied context / and not on the supplied writer.
The above is not the case for testing partial views, so for those you can use this solution:
http://www.brightmix.com/blog/renderpartial-to-string-in-asp-net-mvc/
There are other view engines that do allow you to test the view i.e. Spark.
ps. the concept in asp.net mvc is that you should be able to test the view by using the ViewEngine, but as I understand the asp.net mvc team didn't work around the existing asp.net engine restrictions to be able to do so for their view engine.
You may want to check out the UI Test Helpers that Eric Hexter and the guys with MVCContrib are working on. I haven't had a chance to look at it in depth, but it may help you. I found this link that shows some of the syntax: http://codepaste.net/cw8ie4
I would be interested to know what you find out as I will be doing this pretty soon also.
Interested to know if you find anything for .Net that does this. Our current app is WPF, but we are stuck with trusting Cucumber to touch our Views in all our Features... so yeah, that sucks. Hope you find something and update us.

Resources