So, for the 20th time I am getting a development prepped for MOSS/WSS development. And, again, I forget how to get everything configured and installed. Hopefully this post will save some of you time in doing this.
-
Install MOSS on Server 2008. Not straight forward. In order to get the install working you need to SlipStream the service packs for WSS and MOSS. (use command tool with the /extract command)
-
-
-
Make sure to select "SharePoint Web Part" not "Smart Part".
-
Build the project and run the set-up.
-
In MOSS, find "Site Collection Features" and activate your feature.
-
If you database stuff, set trust level to full in web.config file
-
If you like to load an .ascx file here is some code...
WebPart code
namespace SharePointWebPart1
{
public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
private System.Web.UI.Control control = null;
protected override void CreateChildControls()
{
base.CreateChildControls();
control = this.Page.LoadControl(@"\WATG\MyControl.ascx");
this.Controls.Add(control);
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
control.RenderControl(writer);
}
}
}
.Ascx Html
<%@ Control Language="C#" AutoEventWireup="true" Inherits="SharePointWebPart1.MyControl" %>
<h3>This is my content</h3>
<asp:Button ID="btnTest" runat="server" Text="click me!" />
.Ascx code
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SharePointWebPart1
{
public partial class MyControl : System.Web.UI.UserControl
{
protected Button btnTest;
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Hello");
this.btnTest.Click += new EventHandler(btnTest_Click);
}
void btnTest_Click(object sender, EventArgs e)
{
Response.Write("Great job!");
}
}
}