Thursday, 28 August 2008

Host ASP.NET UserControls in MOSS

I got an interesting change request from my client manager, where they want to host the ASP.NET user control as is in MOSS(This has DLL available). I googled around and found five different ways to do and one mukiway(my way)
1. Deploy the Usercontrol using Smart Part
2. Wrap the UserControl with webpart
3. Modify the UserControl as Webcontrol and deploy the control
4. Recreate this UserControl as new Webpart
5. Deploy this control into 12 hive controltemplates folder along with .cs file

Mukiway:
1. Copy the control and its files into _Layouts/MukiControl/
2. Create a test page in ASP.NET and host the UserControl in that test page
<% Register src="UserControl.ascx" tagname="mukicontrol" tagprefix="muki" %>
In the body tag
<muki:UserControl ID="UserControl" runat="server"/>
save this page as test.aspx

3. GAC the UserControl DLL
3. Mark that DLL as safe entry in web.config file of the hosting site collection
4. Perform IISReset.
5. Add a PageViewer Webpart
6. Select Web Page as option and in the URL field give /_Layouts/MukiControl/test.aspx

Cheers! you are done.

No comments: