Friday, 9 January 2009

Custom controls in ASP.NET MVC

Finally, my article on custom controls in ASP.NET MVC has been published on CodeProject so check it out:


Hardy said...

How about complicated controls with a lot of composition and client side scripts to deal with Ajax?

What is the best approach?


Andrew Gunn said...

Good questions. Compisition is simple normally, because most extension methods return a string of HTML. This string could be a single HTML element a combination. To reduce duplication, you could build up the composite string by calling other extension methods.

I've been putting off controls with AJAX for a while. For inspiration, I'd probably look at the ASP.NET MVC control library by Telerik - I think place JavaScript in separate files but I'm not sure how they reference it from inside their controls. I'll try and come up with some examples ASAP.