PolymorphicPodcast

RSS Feed
Add us to any podcatcher! Just copy in the location below:

Subscribe

Lazy Load JavaScript Files Using ASP.NET AJAX Script Loader

This page initially loads ASP.NET AJAX and the ComponentModel script in order to add a click handler to the button.

When you click the button the script loader loads the DataView control and then binds the client template.

  • {{Name}}

The Code

        Sys.require(Sys.scripts.ComponentModel);

        Sys.onReady(function()
        {
            Sys.addHandler($get("bindButton"), "click", function()
            {
                $get("bindButton").disabled = true;
                Sys.require(Sys.components.dataView, function()
                {
                    Sys.create.dataView("#dv", { data: colors });
                });
            });
        });

        var colors = [
           { Name: "Black" },
           { Name: "Blue" },
           { Name: "White" },
           { Name: "Green" }
        ];
    
Hosted by ORCS Web
All Rights Reserved © Craig Shoemaker 2005 - 2010