Using the HtmlControl Control

If you want to include the same chunk of HTML in multiple pages in a Windows Store app, or you want to break up an existing page into more manageable parts, then you can use the WinJS HtmlControl control. This control requires you to set one option: a URI. You set the URI to indicate the content that you want to load.

Note

You can find the code discussed in this section in the Chapter12\Fragments folder in the GitHub source.

Imagine, for example, that you want to display a page with includes a form for entering both a billing and shipping address. In other words, you want to display the same address form twice (see Figure 12.1).

FIGURE 12.1 Using the HtmlControl to display address forms

In this case, you can ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed 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.