The HTML Message Pattern

The BST pattern forces you to generate any HTML you need in the browser using the JavaScript language. In general, this is a good thing because it allows you to isolate all (or, at least, most) of the presentation logic in the one tier. In addition, by using templates and JavaScript callbacks you can keep up with the inherently dynamic nature of HTML and manage to accommodate characteristics of the data and the user’s expectations.

Templates help you a lot in wedding code flexibility with ease of maintenance. A general-purpose class such as the HtmlListBuilder presented here completes the offering and closes the circle. You can’t reasonably rely on plain JavaScript statements to generate HTML and mix generation with sprinkles ...

Get Microsoft® ASP.NET and AJAX: Architecting Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.