Noocyte’s Weblog

July 22, 2008

ViewEngines in ASP.Net MVC

Filed under: Link — Tags: , — noocyte @ 9:47

In Scotts latest “Weekly Source Code” marathon he takes a look at Spark and NHaml, two view engines for ASP.Net MVC. Take a look at what he says here: Scott Hanselman’s Computer Zen – The Weekly Source Code 30 – Spark and NHaml – Crazy ASP.NET MVC ViewEngines

They both look so-so to me, better than <% … %> in the classic ASP fashion perhaps, but still not what I’d consider really good. But I haven’t had the time to sit down and really try it out either, so that might be the problem… šŸ˜‰

But how would a perfect scenario for a ViewEngine look, Noocyte style? Take a look at this:

Page p = new Page();
p.Title = ViewData.Model.CategoryName; // obviously pseudo code

forach (var product in ViewData.Model) {
p.Add(Html.ActionLink(product.ProductName, “Detail”, new { ID=product.ProductID }));
p.AddImage(“/Content/Images/” + product.ProductID + “.jpg”, product.ProductName
);
p.SimpleLineBreak();
}

I don’t want to type more code here, I think the basic idea has been communicated already. I want to do it in code. That’s it. šŸ™‚
Maybe not the best way, it may even be more cluttered than mix of code and mark-up, I dunno… šŸ˜‰ I think I need to think (doh!) more about this… Perhaps try out some of the ideas! Heck, somebody might have done this (better) than me already?! Propably…

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: