This project is read-only.

The control is very simple to build. Create an ASP.Net web site. Add a User Control (ascx). Drag and drop controls in its Designer and add code in its code behind file. Remove unwanted files and folders like default.aspx, App_Data and so on. Once this is done, add a web deployment project. This does the trick of converting this web site with user control into a custom control. The Web Deployment project can be freely downloaded from Microsoft web site. For Visual Studio 2010, it can be downloaded from the following link.

Once you have added the Web Deployment Project to your web site (which has the control), set its properties. Right click on the Web Deployment project in Visual Studio and click on Property Pages. On the screen that pops up, set the following properties.

Under Compilation, leave the .\Debug in Output Folder, as is. Ensure to uncheck all the checkboxes here.

Under Output Assemblies, select the 1st radio button (Merge all outputs to a single assembly). Provide an Assembly name in the textbox and check the box for Treat as library component. In the Merge options section, check the Version output assemblies checkbox and provide values for Assembly Version and File Version (say,

Under Signing, check the Enable strong naming checkbox and provide a .snk file location. Check the Mark assemblies with AllowPartiallyTrustedCallersAttribute(APTCA) checkbox. This will make the control usable in scenarios, where Full trust is not present.

Under Deployment, check the checkbox for Remove the App_Data folder from output location. Then click OK. All set.

Build the Web Deployment project and navigate to its (of Web Deployment project) Debug\bin location and you will be able to locate the compiled assembly.

Once the dll is ready, add reference it. In my example, I have added it in Default.aspx of an ASP.Net website. In the top of the page (after the Page directive), register this control like below.

<%@ Register TagPrefix="CustomListBoxes" Namespace="ASP" Assembly="CustomListBoxesControl,Version=, Culture=neutral, PublicKeyToken=9497d5948d1b1754" %>

Note: Carefully check the Namespace. It must be "ASP". If you want to understand why, check this dll in Class Viewer or reflector. You will understand it clearly.

Once the control is registered on a page, you can use it like below.

<CustomListBoxes:customlistboxesuc_ascx ID="clb" runat="server" AvailableListBoxLabelHeader="<b>Available List</b>" AssociatedListBoxLabelHeader="<b>Associated List</b>" />

You can set any other exposed property or customize the control further by exposing more properties and methods. You can also invoke the appropriate methods, as shown in the code behind of the sample web site. I used it within Update Panel to avoid screen flicker, during postback.

 Note: Since I have used some LINQ queries within the control, it will work only with .Net versions 3.5 or above.

For your convenience, I have provided the Source Code for the control, the built control assembly(dll) and the sample web site where it is demonstrated. On a high level, it has properties for setting the heading of the Available and Associated list boxes, their respective data sources, their respective text field and value fields methods to bind the lists and so on. You can explore and customize the properties and methods, suited to your needs.

Last edited Oct 30, 2013 at 8:54 PM by venh123, version 4