Posts Tagged ‘AJAX’

External templates for the DataView control: Microsoft Ajax Library 4.0

One of the best things about templates is how portable they are. You can build a template for a particular piece of presentation and then use that template everywhere you need it. In fact you can have several templates to choose from, giving you themes and different ways of displaying the same data.

This is a very powerful and very maintainable technique. Portable template files are a great example of the Don’t Repeat Yourself (DRY) principal and are a good idea for any template that will see reuse.

The new DataView control in the latest beta of the Microsoft Ajax Library version 4.0 (aka the ASP.NET AJAX Library) has a fine template engine built into it. Unfortunately, those templates must be embedded in the page markup. If it’s your project then you can simply use an ascx User Control, or a ContentPlaceHolder or an Html.RenderPartial, but what if you need to be able to use the template on a static file, or a clients site, or even in another framework? You can’t have portable template files that you can just call anywhere. Well, you can, but you have to use a workaround technique.

This is one technique that I came up with for importing a template file into a page. This lets me have one (or a selection of) template files that I can use everywhere for a portable JavaScript widget. It has no dependencies other than the Microsoft Ajax Library.

Read more »

Excessive JavaScript and AJAX: bad practice & broken pages

I’ve written tens of thousands of lines of JavaScript code and I love the language. I have used it on almost every site that I’ve worked on in the last 10 years. It makes web pages and web applications so much better in every way. That is, if it’s used correctly, in moderation.

However, for the last few years it feels like I’ve had to spend more time explaining why we should not use JavaScript than I do actually writing scripts. This is a trend that I’ve noticed more and more as the web matures. An ever increasing number people believe that JavaScript is the solution to everything. Many take this idea so far that they believe it’s okay to say that we don’t support users without JavaScript.

Read more »