In this tutorial, we will learn how to dynamically create and change controls using AJAX. The tutorial itself is very simple, but the principle can be applied to any control, giving powerful results.

We will simply create 3 custom controls and use a dropdown list to change these controls.

We create three WebControls: BlueControl.ascx, GreenControl.ascx and RedControl.ascx all with similar code as below:

On Default.aspx, we add a ScriptManager, UpdatePanel, DropDownList and a PlaceHolder:

The code-behind will look something like this:

Web.config will look something like this:

Download Source Files