Hugoware

The product of a web developer with a little too much caffeine

Archive for October 5th, 2009

MVC Post Round-Up

with one comment

I thought I’d bring back a few of my previous ASP.NET MVC posts just in case they were missed before.

Include Stylesheets and Scripts To Your Header With MVC

A while back I wanted to include some stylesheets in my header of a MVC View, but I wanted to do it from a WebControl. Since you’re using inline code the standard Page properties like “header” aren’t going to do you much good (since you’re already in the render event). Fortunately, with a little magic with the HttpContext.Current.Response.Filter stream, you can make all the changes you need before the content is sent to the user.

Using WebControls With Inline MVC

Just for fun I wanted to see if it was possible to actually create WebControls that worked inline with MVC Views. It took a little bit of work to do (it actually ended up spanning 4 different posts) but it finally came together fairly well.

This series was actually inspired at the idea of just rendering controls inline, without postbacks.

Combining MVC with Existing Web Services

I like the idea behind WebServices, but the hassle of creating SOAP envelopes and modifying headers makes them difficult to use in places other than .NET applications. Being able to create a MVC Controller that automatically maps to an existing WebService would make it easier to use the same functionality, but all from a standard HTTP call.

Anonymous Types (Sorta MVC related…)

If you’ve worked with Anonymous Types in MVC then you’ve probably noticed that you can’t just pass them into your view and expect them to be available. Personally, recommend creating a unique class for anything that you’re passing into a view – but if you’re looking for something that you can use in a hurry, then this Anonymous Type wrapper class might come in handy. Just pass in an anonymous type and the class does the rest!

You can change values, assign new methods — basically you have a little bit of dynamic programming goodness all wrapped into a single .NET class!

Written by hugoware

October 5, 2009 at 7:30 pm