You can reuse ASP.NET Web Parts in your MOSS Web Site by exporting them to create .webpart files, which are XML files that contain details about your Web Part. To enable export functinality you need to do some modifications to your Web Part code and your configuration settings.
After you have a .webpart file, you can import it into any MOSS Web Site.
Step 1: To export an ASP.NET Web Part
1. In your Web Part code, set the ExportMode property to allow properties to be exported. In the following code, we set the value to All, which allows sensitive properties to be exported.
this.ExportMode = WebPartExportMode.All;
2. Modify the <system.web> section of the web.config file as follows:
<system.web> <webParts enableExport ="true"/> </system.web>
3. From the Web Part menu, choose Export to create a .webpart file you can import into a Windows SharePoint Services Web Part Page.
Save file on Disk. Let’s say file name is mywebpart.webpart Please not you may get some security warning about properties set for the Web Part. Reset properties if you do not want this values to be exported.
Step 2: To import a mywebpart.webpart file into Windows SharePoint Services
1. Place the assembly for your Web Part in the bin or the global assembly cache.
If you place your assembly in the global assembly cache, your assembly must be strong named and run with full trust code permissions by default. The Web Part is available to all Web applications.
If you place your assembly in the bin, you do not have full trust code permissions when your Web Part executes. Because the permissions for the bin directory are very low by default, for this add following code into AssemblyInfo.cs file of your web part project.
[assembly: System.Security.AllowPartiallyTrustedCallers]
2. Add the Web Part to the Safe Controls list in your web.config file, for example:
<SafeControl Assembly="MyWebPart" Namespace="MyWebParts" TypeName="*" Safe="True"/>
3. In Design mode, select Add a web part. At the bottom of the Add Web Parts dialog box, click Advanced Web Part gallery and options.
4. On the Add Web Parts pane, select Browse ->Import menu and then navigate to the .webpart file you created in the preceding procedure.
5. Click Upload and your Web Part appears in the list of Uploaded Web Parts.
6. Drag it into a Web Part zone on the page and you should see the same Web Part as on your ASP.NET page.