I searched on google for some clarifications but I didn't find the answers I've been looking for.

I want to deploy a delegate which would perform some custom functionality. That is why with a delegate I want to ship a classe with code, so I did a following:

I added a classe:

public class SomeClassForDelegate: WebControl
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
        writer.WriteLine("<p>Write some text</p>");

Basically this classe will write just a text. The reason why I do that is just to test if my classe is being used, normally I'll add totaly difirent functionality.

Then I have a delegate declaration in element.xml:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control Id="AdditionalPageHead" ControlAssembly="$SharePoint.Project.AssemblyFullName$" ControlClass="mysolution.SomeClassForDelegate"  Sequence="90" />

Which I deploy with a feature.

Everything goes good and well but at the end I don't see the result.

What am I doing wrong?

Update: Solved

The problem was that the webcontrol was not put as safe control. So in an element.xml I added whole folder as a safe place. And it was working.

Thank you for input, especially Dribbel!

  • 1
    Are you just looking at the page, or at the page-source. The text will be inserted in the <head> element of the page and thus will not render in the browser. And Did you specify a Sequence value in your element file? – Dribbel Aug 3 '12 at 6:15
  • Yep, I forgot the sequence and I added it. But still nothing :( – Shkipper Aug 3 '12 at 6:31
  • Did you register it as safe control? Try adding a breakpoint, what does the ULS-log say? Check if it is correctly registered with this: blog.mastykarz.nl/… – Dribbel Aug 3 '12 at 7:29
  • What Scope is the Feature? – James Love Aug 3 '12 at 7:52
  • ok with the powershell script it seems it is ok it shows in controlclass for the additionialheaderpage: the src: mysolution.SomeClassForDelegate. But why it doenst do anything then? i even write some logs from Render or OnLoad methods but nothigs come in. – Shkipper Aug 3 '12 at 8:00

Please check the following:

  • Is there any warning in the ULS-logs?
  • Is the sequence set correctly?
  • Does adding a breakpoint help (this checks if the code is actually loaded)
  • Check if the Control is referenced at all in the page using http://blog.mastykarz.nl/checking-which-delegate-controls-activated-site/ ?
  • Is the control registered as safe (check in the web.config after deploying)? Not safe controls will generate an error in the ULS-logs.
| improve this answer | |
  • You were right the control was not added as safe ) – Shkipper Aug 3 '12 at 8:38
  • @Shkipper can you share the code for your solution. – Gabriel Smoljár Sep 29 '16 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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