Listing 1: C# • Generate the Base Code

The WebPart Visual Studio 2005 template generates the base code for you. References to SharePoint have been added, as well as the "using" statements, a GUID for the WebPart identification, and the override of the "Render" method. The commented code can be used directly to print text to the screen. After compilation, the template generates the necessary SharePoint files and installs the WebPart in the local SharePoint instance (if there is one).

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace Web_Part1
{
	[Guid("632ef71f-b07f-4568-85fd-87280aa4e873")]
	public class Web_Part1 : 
		System.Web.UI.WebControls.WebParts.WebPart
	{
		protected override void Render(HtmlTextWriter writer)
		{
			// TODO: Add custom rendering code here.
			// writer.Write("Output HTML");
		}
	}
}
comments powered by Disqus

Featured

  • Mastering AI Development and Building AI Apps with GitHub Copilot

    Two Microsoft experts explain how GitHub Copilot is evolving from a coding assistant into a broader platform for building, customizing and testing AI-powered developer workflows.

  • VS Code 1.123 Adds Agent Session Sync, 1M Context Windows

    Microsoft released Visual Studio Code 1.123 on June 3, adding agent-focused features, larger model context support, integrated browser updates and a new delay for some automatic extension updates.

  • Copilot Billing Shock Hits Developers

    Developer complaints about GitHub Copilot's new usage-based billing model have centered on unexpectedly rapid AI credit consumption, and neither GitHub nor Microsoft has responded directly to the backlash, though they have previously published guidance to lessen model usage costs.

  • Hands On with GitHub Copilot App Technical Preview: Turning a Blazor Issue into a PR

    GitHub's brand-new Copilot desktop app, in technical preview, handled a small Blazor issue from planning through pull request creation, but the hands-on test also showed why developers still need to verify agent work in the running app before merging.

Subscribe on YouTube