Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

How to Create Installer (.cab) for web part?

, 30 Jun 2005
A sample project (Hello world webpart and installer project) and walk through for creating an installer for web part that will install the webpart on the share point portal site.
wpsamplehelloworld.zip
WpSampleHelloWorld
bin
Release
WpSampleHelloWorld.dll
HelloWorld.dwp
Helloworld.snk
Lplus.gif
minus.gif
plus.gif
r.gif
Rminus.gif
WpSampleHelloWorld.csproj.user
WpSampleHelloWorldInstaller
Release
WpSampleHelloWorldInstaller.CAB
WpSampleHelloWorldInstaller.vdproj
Installer
WpSampleHelloWorldInstaller.CAB
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;

namespace WpSampleHelloWorld
{
	/// <summary>
	/// Description for HelloWorld.
	/// </summary>
	[DefaultProperty("Text"),
		ToolboxData("<{0}:HelloWorld runat=server></{0}:HelloWorld>"),
		XmlRoot(Namespace="WpSampleHelloWorld")]
	public class HelloWorld : Microsoft.SharePoint.WebPartPages.WebPart
	{
		private const string defaultText = "";

		private string text = defaultText;

		[Browsable(true),
			Category("Miscellaneous"),
			DefaultValue(defaultText),
			WebPartStorage(Storage.Personal),
			FriendlyName("Text"),
			Description("Text Property")]
		public string Text
		{
			get
			{
				return text;
			}

			set
			{
				text = value;
			}
		}
	
		/// <summary>
		///	This method gets the custom tool parts for this Web Part by overriding the
		///	GetToolParts method of the WebPart base class. You must implement
		///	custom tool parts in a separate class that derives from 
		///	Microsoft.SharePoint.WebPartPages.ToolPart. 
		///	</summary>
		///<returns>An array of references to ToolPart objects.</returns>
//		public override ToolPart[] GetToolParts()
//		{
//			ToolPart[] toolparts = new ToolPart[2];
//			WebPartToolPart wptp = new WebPartToolPart();
//			CustomPropertyToolPart custom = new CustomPropertyToolPart();
//			toolparts[0] = wptp;
//			toolparts[1] = custom;
//			return toolparts;
//		}
	
		/// <summary>
		/// Render this Web Part to the output parameter specified.
		/// </summary>
		/// <param name="output"> The HTML writer to write out to </param>
		protected override void RenderWebPart(HtmlTextWriter output)
		{
			output.Write("Hello World");
			output.Write(SPEncode.HtmlEncode(Text));
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Rajshekar Chittoory
Web Developer
United States United States
Rajshekhar Chittoory

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150128.1 | Last Updated 1 Jul 2005
Article Copyright 2005 by Rajshekar Chittoory
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid