SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a simple project to Customize a Delegate Control in SharePoint 2010 such as in msdn article (

Source code: Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
namespace ShowRibbon
    class ShowRibbonControl : WebControl
        protected override void OnLoad(EventArgs e)
            string helloAlert = "alert('Hello, world!');";
            this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "popup", helloAlert, true);




<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
  <Control Id="AdditionalPageHead"

I add SafeControl to Empty Element with Elements.xml, but when I run my solution and set breakpoint in OnLoad method, it is not reached. What may be the reason?

share|improve this question
I may be pointing at the obvious, but have you made sure you have attached the debugger successfully and there is no issue with source code not matching the assembly loaded? Have you enabled tracing and looked at the Control Tree? Has your control been loaded? Has the feature been successfully activated? – Alexey Krasheninnikov Jan 31 '12 at 19:54

I show you my custom search small input box. These is my Elements.xml:

<Elements xmlns="">
  <Control  Id="SmallSearchInputBox"
    ControlSrc ="~/_controltemplates/Piaggio.Dealer.Portal/SmallSearchInputBoxDelegateControl.ascx">

and these is part of my ascx control:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SmallSearchInputBoxDelegateControl.ascx.cs"
Inherits="" %>

that's works perfectly

look at this link:

share|improve this answer

Please check your web.config to see if your SafeControl entry is really inserted and specifies the correct assembly and class. I didn't understand from your description what you did to add it. A missing or incorrect SafeControl entry will most likely be the cause of the control not being used. BTW, if this is the case, you can also see it in the ULS log. Kind regards, Matthias

share|improve this answer

Make your ShowRibbonControl class a public class. That will make the difference and it will start working and will hit to the OnLoad method.

share|improve this answer

If you are not seeing any exception on site load then I think you control is working fine, remove the dll from GAC / BIN and see it shoulf throw an error.

Sometimes this.Page.ClientScript.RegisterClientScriptBlock doesn't work in Server control, please try using this.Page.ClientScript.RegisterStartupScript instead.

Also, see the source code of the page to see whether the script has been added.

Edit : Please check the webconfig, if the namespace has been added under safecontrols

share|improve this answer

Did you activate the feature that activates the Delegate Control?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.