Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We all know about delegate controls and steps that should be done to use it, but what SharePoint exactly do in time when we activate feature?

It looks like it creates a copy of control's declaration, localizes strings and stores a new copy somewhere. Then this copy is used to populate control's properties in the runtime.

Could you clarify all process for me?

share|improve this question
add comment

1 Answer

Opening up the "DelegateControl" object in Reflector it is basically just a dynamic control builder.

It queries the current context to get the list of all registered controls (i.e. features with a <Control> element which uses the same ControlId as the Delegate Control). These could be features from any of the available scopes (Farm, Web Application, Site or Web).

If the Delegate Control is set to AllowMultipleControls then it adds ALL of them (in order of the Sequence number). If AllowMultipleControls is false then it just gets the control with the lowest Sequence number. These are loaded as SPControlElement objects.

It then calls the BuildCustomControl method for each of the SPControlElements objects (which in turn uses an internal SPUtility method to create a new System.Web.UI.Control object from that definition).

  • If it is a server control then it dynamically loads it from the Assembly / Classname information
  • If it is a user control then it dynamically loads it from the virtual path

If your <Control> element included any child <Property> elements then these are also added to the control declaration as attributes.

..

From that point you are on to whatever .NET code your control is using to render itself.

share|improve this answer
add comment

Your Answer

 
discard

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.