User Control in Page Layout

Hi

I am creating a page layout for our ECM site. I want to use my .net user control in page layout.

Here is what I have done.

Created a user control, strong named it and deployed it in GAC

Added safe control entry in web.config

Registered my user control on the layout page and then wrap the control tag in the code.

I am able to create page using my page layout but I dont see my user control. I dont get any error either.

If I print some text on user control load event then I am getting that text but I dont see the page layout. I've put my control under

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

Am I missing something or I can not use user control in page layout ?

Any help would be greatly appreciated.

Regards

[892 byte] By [AmitV] at [2007-12-29]
# 1

I did this as described below.

1) Created user control.

2) Pasted both "ascx" and "ascx.cs" to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES

3) Write a Class Lib (dll) , sign with key, deploy to GAC.

protected override void CreateChildControls()
{
base.CreateChildControls();
this.Controls.Add(this.Page.LoadControl("~/_controltemplates/MyFolder/MyUserControl.ascx"));
}

4) iisreset

5) In SiteCollection settings, Galleries , WebParts, add web part to site coll. (I think you missed this step)

6) Use wherever you want.

Abdulkadir at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 2

Hi Abdul

Thanks for your reply.

I see what you are doing. You are loading user conrol using web part.

In my page layout I dont have web part zone.

I want to know if its possible to load user control in page layout without using web part.

Regards

Amit

AmitV at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 3
Hi Amit,

Did you get it?

I'm trying the same thing: use a ascx inside a page layout without web parts.

Could you give me some advices?

Thanks, any info will be appreciated.

Pablo. at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...
# 4
Hi all,
There is an excellent tutorial on customizing user control, i.e. delegate control on layout page inside Sharepoint SDK. You can use your control as delegate control.
Basically, what you need to do is:
1. Create folder in Local_Drive:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/FEATURES that is named as your control. In that folder you create files feature.xml and control.xml
2. Create GUID for your new feature and paste it into feature.xml
3. Inside control.xml you create a reference to your control that is preferably inside CONTROLTEMPLATES folder
4. Install and activate feature using stsadm
Now you can use it in your page layouts inside DelegateControl tag.
Yes... here is a link to full sample
http://msdn2.microsoft.com/en-us/library/ms470880.aspx

HTH
Dragan

panjkov at 2007-9-5 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Design and Customization...

SharePoint Products and Technologies

Site Classified