Use your ASP .NET WebControl in MOSS 2007 with Sharepoint Delegate Control


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

Comments (14)
  1. P. says:

    Question: What about codebehind-files? If this is allowed, where and how to deploy those?


  2. MSDNTST says:

    As I mentioned, with code behind files:

    you need to copy the .cs or .vb file with the .ascx file

  3. Deepa says:

    After executing the stasdm.exe my new feature got enabled in the Sharepoint 3.0 Central Administration page. But in my sharepoint site am getting error message like "Critical error encountered in this page".

    Can you help me out to figure out this issue?

    Thanks in Advance…

  4. Troels says:


    But i dont want to edit a page in SharePoint Designer to insert the control on a production enviroment.

    How do i save the edited page in my development enviroment and redeploy it on the production enviroment (on a specific site)?

  5. Ravi says:

    i have developed an user control that uses xml, css and js files where do i put these files when i deploy the user control to moss 2007?

  6. Sriram says:

    What about the dlls that are created by ASP.Net user control ? Does sharepoint compile the sources ‘on-the-fly’ to generate these dlls?

    Secondly, this feature cannot be a web-part feature, correct?

  7. malvika says:

    The moment i install this "Stsadm -o installfeature -filename ASPNETControlfeature.xml -force"  and

    Open Sharepoint 3.0 central Administration and go to Central Administration>Operations>Global Configuration>Manage Farm Features    it is giving following error

    "You are not authorized to view this page"

  8. Dregfdgf says:

    <a href= ></a>

    <a href= ></a>

    <a href= ></a>

    <a href= ></a>

    <a href= ></a>

  9. Jonathan says:

    Friend you could help me, I could initiate in the administrator of sharepoint the user control “ASPNETControl”, but I cannot use it in the page, leaves to me that “SharePoint: DelegateControl” is not compatible with IE, my mail is

  10. Krutika says:


    I had followed all steps. On inserting the DelegateControl in my default.aspx of MOSS site, It is not display the usercontrol on refreshing the site. I am even not getting any kind of error in my eventlog.

    Can you plz let me know where can the problem be ?

  11. jesus libreros says:

    Hi, i had followed all steps . but the delegate control is not visible.

    can you help me please, to resolve this trouble.

  12. Vince says:

    Did you guys ensure the line :

    <%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

    was at the root of your .ASPX page ? Otherwise Sharepoint:Delegate is not know…

  13. mauricio says:

    Yes, the tag is there but the UC is not visible.

    If I change the ControlId to SmallSearchInputBox it starts working.

    If I change it to AnyNonExistingThing nothing happens, no error is raised and obviously nothing is visible.

    I see the feature at operations level perfectly but only there.

Comments are closed.

Skip to main content