In the new release of Sharepoint Server (MOSS 2007), a very interesting control is provided,  "DelegateControl", under Microsoft.SharePoint.WebControls.SPControl. With this control we can easily reuse our ASP.NET control on SPS pages. Now, an ASP .NET programmer can name himself a "part time SPS Web part developer" :)

Here is sample on how you can use DelegateControl on a sharepoint page:

1. Create an ASP .NET WebControl (ASPNETControl.ascx) file as following:


<%@ Control Language="C#" AutoEventWireup="true" ClassName="ASPNETControl"   %>

<script runat ="server" >

 protected void Button1_Click(object sender, EventArgs e)


        TextBox1.Text = System.DateTime.Now.ToShortDateString();    



<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />


2. Create a folder "ASPNETControl" under:


\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES

And Copy the file (ASPNETControl.ascx) to this folder.


3. Create two xml file feature.xml (fixed name, must be feature.xml) and Control.xml:



<?xml version="1.0" encoding="utf-8" ?>

<Feature Id="62D5F317-A793-4328-A250-50CBE1F5B70E"



  Description="Test ASPNET control"


  xmlns="" >


      <ElementManifest Location="Control.xml" />





<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="" >

    <Control Id="ASPNETControl"


          Sequence="100" >




4. Create a folder "ASPNETControl" under following folder:

\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

And copy the two XML files into it.


5. Execute stsadm.exe to run following command:


Stsadm -o installfeature -filename ASPNETControl\feature.xml -force


6. Open Sharepoint 3.0 central Administration, in


Central Administration>Operations>Global Configuration>Manage Farm Features   

You will notice this new feature has been enabled by default



7. Open your site with SharePoint Designer 2007, and add following line in the default.aspx:


<SharePoint:DelegateControl ControlId="ASPNETControl" RunAt="server" />

Save the page, and view your site again. You will see the control has been updated on it.


Additionally, for those ASP .NET controls with code behind, you need to copy the .cs or .vb file with the .ascx file