Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
General Reference
 Walkthrough: Creating a Basic Share...
Community Content
In this section
Statistics Annotations (26)
Collapse All/Expand All Collapse All
This page is specific to
The 2007 product release

Other versions are also available for the following:
Walkthrough: Creating a Basic SharePoint Web Part

This programming task includes the steps for creating a basic custom Windows SharePoint Services Web Part. It is a simple Web Part that allows you to change the Web Part’s Title property, which is a Windows SharePoint Services WebPart base class property that sets the text in the title bar of the Web Part.

Important Important:

Beginning with Windows SharePoint Services 3.0, the Windows SharePoint Services Web Part infrastructure is built on top of the Microsoft ASP.NET 2.0 Web Part infrastructure and Web Parts that derive from the ASP.NET WebPart class are completely supported in Windows SharePoint Services. You should create ASP.NET Web Parts whenever possible.

For more information about choosing the best Web Part base class from which to derive, see Developing Web Parts in Windows SharePoint Services in the Windows SharePoint Services Software Development Kit (SDK). For more information about ASP.NET Web Parts, see the Web Parts Control Set Overview in the ASP.NET documentation.

Microsoft Visual Studio 2005

Windows SharePoint Services 3.0

Web Parts are based on ASP.NET Web Form Controls. You create Web Parts in Microsoft Visual C# or Microsoft Visual Basic by using the ASP.NET Web Control Library template.

To create a new Web Control Library project

  1. Start Visual Studio 2005.

  2. On the File menu, point to New, and then click Project.

  3. In the New Project dialog box, click Visual C# Projects or Visual Basic Projects, and then select the Web Control Library template.

  4. Type SimpleWebPart as the name and specify the location for the project files, and then click OK.

To create a Web Part, you need to add a reference to the Microsoft.SharePoint assembly (Microsoft.SharePoint.dll) in your Web Control Library project.

To add a reference to Microsoft.SharePoint.dll

  1. On the Project menu, click Add Reference.

  2. On the .NET tab, double-click Windows SharePoint Services.

  3. Click OK.

By default, the AssemblyVersion property of your project is set to increment each time you recompile your Web Part. A Web Part page identifies a Web Part with the version number that is specified in the web.config file. With the AssemblyVersion property set to increment, if you recompile your Web Part after importing it into a Web Part page, the Web Part framework will look for the version number you specified in the web.config file. If the version number does not match, an error will occur. To prevent the version number of your Web Part from incrementing each time you recompile, you need to set the version number in the AssemblyInfo file.

Since you are creating signed code, you must also tell your assembly to allow partially trusted code calls. By default, any strong-named assembly that does not explicitly opt in to its use by partially trusted code will be callable only by other assemblies that are granted full trust by security policy.

To set the version number and allow partially trusted callers

  1. In Solution Explorer, double-click the AssemblyInfo file

  2. Edit the line:

    C#
    [assembly: AssemblyVersion(“1.0.*”)]
    Visual Basic
    <Assembly: AssemblyVersion(“1.0.*”)>

    so that it reads:

    C#
    [assembly: AssemblyVersion(“1.0.0.0”)]
    Visual Basic
    <Assembly: AssemblyVersion(“1.0.0.0”>
  3. Add the following line to the top of the file:

    C#
    using System.Security;
    Visual Basic
    Imports System.Security;
  4. Add the following line to the bottom of the file:

    C#
    [assembly: AllowPartiallyTrustedCallers]
    Visual Basic
    <Assembly: AllowPartiallyTrustedCallers()>

If you are creating multiple Web Parts, you should generally use the same namespace across all of your Web Parts. By default, the Web Control Library assigns the namespace the same name as your project. For this example, we are using the arbitrary namespace of MyWebParts for the WebPart class. After you create the project, a blank class file is displayed. You can change the default class name of WebCustomControl to easily identify your new Web Part.

To rename the class and namespace

  1. Rename the default class by selecting WebCustomControl1 in Solution Explorer, right-click, click Rename, and type SimpleWebPart as the file name.

  2. For C#, change the Web Part namespace by editing the line:

    C#
    namespace SimpleWebPart

    so that it reads:

    C#
    namespace MyWebParts
  3. For Visual Basic, right-click on the the SimpleWebPart project in the Solution Explorer and click Properties. Replace the text in the Assembly name and Root namespace text boxes to MyWebParts.SimpleWebPart

To make it easier to write a basic WebPart class, you should use the using directive in C# or the Imports directive in Visual Basic to reference the following namespace in your code:

To add a namespace directive

  • Add the following using or Imports directive near the top of your code:

    C#
    using Microsoft.SharePoint.WebPartPages;
    Visual Basic
    Imports Microsoft.SharePoint.WebPartPages

By default, the Web Control Library template creates a custom control that inherits from the System.Web.UI.Control class (a parent class of both the ASP.NET and SharePoint WebPart classes). To create a SharePoint Web Part, you should inherit from the Microsoft.SharePoint.WebPartPages.WebPart base class.

To inherit from the Web Part base class.

  • Replace this line of code:

    C#
    public class SimpleWebPart : WebControl
    Visual Basic
    Public Class SimpleWebPart
       Inherits WebControl

    with this line:

    C#
    public class SimpleWebPart : WebPart
    Visual Basic
    Public Class SimpleWebPart
       Inherits WebPart

The WebPart base class seals the Render method of System.Web.UI.Control because the Web Part infrastructure needs to control rendering the contents of a Web Part. For this reason, custom Web Parts must override the RenderWebPart method of the WebPart base class.

To use the RenderWebPart method.

  • Replace this line of code:

    C#
    protected override void Render(HtmlTextWriter output)
    Visual Basic
    Protected Overrides Sub RenderContents(ByVal output as HtmlTextWriter)

    with this line:

    C#
    protected override void RenderWebPart(HtmlTextWriter output)
    Visual Basic
    Protected Overrides Sub RenderWebPart(ByVal output as HtmlTextWriter)

After you complete the previous steps, you can define the logic and rendering for your Web Part. For this part, we will write some basic ASP.NET code to create two controls: a text box and a button that will set the Title property of the Web Part.

To define the logic and rendering of your Web Part

  1. Create two user interface objects by adding the following code near the top of the SimpleWebPart file.

    C#
    Button saveTitle;
    TextBox newTitle;
    Visual Basic
    Public saveTitle as Button
    Public newTitle as TextBox
  2. Create the button handling event by adding the following code inside the class.

    C#
    public void saveTitle_click(object sender, EventArgs e)
    {
         this.Title = newTitle.Text;
         try
         {
              this.SaveProperties = true;
         }
         catch (Exception ex)
         {
              this.Title = "Error: " + ex.Message;
         }
    }
    Visual Basic
    Public Sub saveTitle_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.Title = newTitle.Text
        Try
            Me.SaveProperties = True
        Catch ex As Exception
            Me.Title = "Error: " & ex.Message
        End Try
    End Sub
  3. Override the CreateChildControls() method by adding the following code inside the class.

    C#
    protected override void CreateChildControls()
    {
         //Create text box
         newTitle = new TextBox();
         newTitle.Text = "";
         Controls.Add(newTitle);
    
         //Create button
         saveTitle = new Button();
         saveTitle.Text = "Set Web Part Title";
         saveTitle.Click += new EventHandler(saveTitle_click);
         Controls.Add(saveTitle);
    }
    Visual Basic
    Protected Overrides Sub CreateChildControls()
        'Create text box
        newTitle = New TextBox()
        newTitle.Text = ""
        Controls.Add(newTitle)
    
        'Create button
        saveTitle = New Button()
        saveTitle.Text = "Set Web Part Title"
        AddHandler saveTitle.Click, AddressOf saveTitle_Click
        Controls.Add(saveTitle)
    End Sub
  4. Replace the RenderWebPart() method with the following line of code.

    protected override void  RenderWebPart(HtmlTextWriter output)
    {
         RenderChildren(output);
    }
    Visual Basic
    Protected Overrides Sub RenderWebPart(ByVal output as HtmlTextWriter)
        RenderChildren(output)
    End Sub

Web Parts are designed to be distributed over the Internet or an intranet. For security reasons, when you create a custom Web Part, you should give it a strong name to ensure that the Web Part can be trusted by your users. For more information about strong naming, see Deploying Web Parts in Windows SharePoint Services and also Assembly Signing Frequently Asked Questions.

To assign a strong name to an assembly

  1. In Solution Explorer, right-click on the SimpleWebPart project and click Properties.

  2. In the SimpleWebPart properties, click the Signing tab on the left side.

  3. On the Signing tab, check the Sign the assembly checkbox.

  4. Select New in the Choose a strong name key file drop-down menu.

  5. In the Create Strong Name Key dialog, type SimpleWebPartKey and uncheck Protect my key file with a password.

  6. Now, the assembly will be signed when it is built.

After you add all of the preceding code, you can build your sample Web Part.

To build your Web Part

  • On the Build menu, click Build Solution.

After the Web Part is built, you must copy the resulting DLL to the bin directory.

To copy your DLL to the bin directory

  1. On the file system, locate the SimpleWebPart.dll file. The default location for Visual Studio 2005 is C:\Documents and Settings\UserName\My Documents\Visual Studio 2005\Projects\SimpleWebPart\SimpleWebPart\bin\Debug.

  2. Copy the SimpleWebPart.dll file from the output directory to the Web application root bin directory. The default location of the Web application root for is C:\Inetpub\wwwroot\wss\VirtualDirectories\PortNumber\bin.

    For more information, see How to: Find the Web Application Root.

provides a SafeControls list to prevent users from arbitrarily adding server-side code within ASPX pages. The SafeControls list is a list of approved controls and Web Parts specific to your SharePoint site that you have designated as safe for invocation on any ASPX page within your site. This list is contained in the web.config file in your Web application root. The local path contains the physical location of the web.config file.

By default, the trust level for this server is WSS_Minimal, which does not allow access to the Windows SharePoint Services object model. For this Web Part to set the SaveProperties property, you must perform one of the following three actions:

  • Create a custom policy file for your assembly, or

  • Install your assembly in the global assembly cache, or

  • Increase the trust level for the entire virtual server.

In this example, you will increase the default trust from WSS_Minimal to WSS_Medium in the web.config file.

Note Note:

The web.config file is located in the folder where the virtual directory for the Web site runs. It is usually located in the following directory: c:\inetpub\wwwroot\wss\VirtualDirectories\PortNumber, but your administrator may have set up your directory differently and this may not be the location of the file.

You can find the location of your web.config file by using the Internet Information Services (IIS) snap-in. The IIS snap-in is an administration tool for IIS that has been integrated with other administrative functions. To launch the IIS snap-in and locate the web.config file:

  1. Click Start, point to Programs, point to Administrative Tools, and click Internet Information Services (IIS) Manager.

  2. Expand the node that is the name of your computer, and expand the Web Sites item in the tree.

  3. Locate the web site that is running your Windows SharePoint Services installation (often it is Default Web Site).

  4. Right-click and select Properties.

  5. Select the Home Directory tab.

To increase the default trust level and add a SafeControl entry for your Web Part

  1. Open the web.config file in the Web application root.

  2. In the level attribute of the trust section, change WSS_Minimal to WSS_Medium.

  3. In the SafeControls section of your web.config file, add a SafeControl entry for your custom assembly as follows.

    Xml
    <SafeControl Assembly="SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=PublicKeyToken" Namespace="MyWebParts" TypeName="SimpleWebPart" Safe="True"/>
  4. Replace the PublicKeyToken with the actual value for your Web Part's assembly. To determine the correct PublicKeyToken for your Web Part, use the sn.exe command-line utility.

    sn.exe -T C:\inetpub\wwwroot\wss\VirtualDirectories\PortNumber\bin\SimpleWebPart.dll

A Web Part definition file (.dwp) is a simple XML file that contains property settings for a single Web Part. To import your Web Part into a Web Part page, simply upload the .dwp file. After uploading the Web Part, you can display the Web Part by dragging it into one of the zones of the Web Part page.

Two properties are required in the .dwp file: Assembly and TypeName. However, to display a default name and description for the Web Part after it is imported, you should also include the Title and Description properties. If you want to set other Web Part properties during import, you can also define them in a .dwp file. A .dwp file takes the following form.

Xml
<?xml version="1.0"?>
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
   <Assembly>AssemblyName(with no .dll extension),
     Version=VersionNumber, Culture=Culture,
     PublicKeyToken=PublicKeyToken</Assembly>
   <TypeName>WebPartNameSpace.WebPartClassName</TypeName>
   <Title>DefaultWebPartTitle</Title>
   <Description>WebPartDescription</Description>
</WebPart>

To create a DWP file

  1. Copy and paste the following XML into a new text file.

    Xml
    <?xml version="1.0"?>
    <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
       <Assembly>SimpleWebPart, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=PublicKeyToken</Assembly>
       <TypeName>MyWebParts.SimpleWebPart</TypeName>
       <Title>My Simple Web Part</Title>
       <Description>A simple Web Part</Description>
    </WebPart>
    Important Important:

    You must replace PublicKeyToken in the XML above with the public key token of your assembly.

  2. Save this file as SimpleWebPart.dwp in the bin directory of the Web application root.

To use and test your Web Part, import it into a Web Part page on a server that is running Windows SharePoint Services or Microsoft Office SharePoint Server 2007.

To import your Web Part

  1. Navigate to the page on your SharePoint site where you want the Web Part to be accessible.

  2. In the Web Part page, click Site Actions, and select Site Settings.

  3. On the Site Settings page, click Web Parts under the Galleries heading.

  4. On the toolbar in the Web Part gallery, click Upload.

  5. On the Upload Web Part page, click Browse and select the .dwp file that you created.

    Note Note:

    This should be in C:\inetpub\wwwroot\wss\VirtualDirectories\PortNumber\bin\.

    Click OK.

  6. Navigate back to the Web Part page. In the Web Part page, click Site Actions, and select Edit Page.

  7. In your preferred zone, click Add a Web Part and check the box next to My Simple Web Part in the dialog box. Click Add.

  8. After the Web Part is added to the zone, type some text in the text box and click Set Web Part Title to test the Web Part.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
This page needs revision      Lars Wilhelmsen ... sarangasl   |   Edit   |   Show History

"It contains references to .NET 1.1 / Visual Studio .NET 2003.
I couldn't find the Microsoft.Sharepoint assembly in the .NET tab of the Add Reference dialog box either, even if I installed WSS3.0 together with VS2005.

When you try to add reference dont look for Microsoft.Sharepoint name in Add Reference Dialog box, Look for Microsoft Windows Sharepoint Services in it."


Try this ,

http://sarangasl.blogspot.com/2009/09/custom-sharepoint-webparts.html

Flag as ContentBug
Ditto on 'Revision'      GtlBearFL ... sarangasl   |   Edit   |   Show History
Although the references are outdated, the content cannot be followed successfully. Please check content for accuracy prior to posting.


Tags What's this?: Add a tag
Flag as ContentBug
Please comment on the needed revisions      CRSCoder   |   Edit   |   Show History

I was able to do this "successfully". Here are some of the things I did that were different than above:

First - common sense - in the section Defining the logic and rendering of your webpart . Make sure to remove all of the <b> and </b> tags...OK that's a bit of entertainment as well.

If you attempt to build and see several errors "Caption is deprecated..." etc. check your "Using" directives and make sure they match the ones in the example. It may be overkill, but here are the contents of my file:

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Xml.Serialization;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.HtmlControls;


namespace MyWebParts
{

[Guid("60487385-c231-4274-8536-64e5be432bd5")]
//public class SimpleWebPart : System.Web.UI.WebControls.WebParts.WebPart
[XmlRoot(Namespace="MyWebParts")]
public class SimpleWebPart : Microsoft.SharePoint.WebPartPages.WebPart
{

private const string defaultText = "hello";
private string text = defaultText;

// Declare variables for HtmlControls user interface elements.
HtmlButton _mybutton;
HtmlInputText _mytextbox;


// Event handler for _mybutton control that sets the
// Title property to the value in _mytextbox control.
public void _mybutton_click(object sender, EventArgs e)
{
this.Title = _mytextbox.Value;
try
{
this.SaveProperties = true;
}
catch
{
//Caption = "Error... Could not save property.";
this.ToolTip = "Error... Could not save property.";

}
}

// Override the ASP.NET Web.UI.Controls.CreateChildControls
// method to create the objects for the Web Part's controls.
protected override void CreateChildControls()
{
// Create _mytextbox control.
_mytextbox = new HtmlInputText();
_mytextbox.Value = "";
Controls.Add(_mytextbox);

// Create _mybutton control and wire its event handler.
_mybutton = new HtmlButton();
_mybutton.InnerText = "Set Web Part Title";
_mybutton.ServerClick += new EventHandler(_mybutton_click);
Controls.Add(_mybutton);
}

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

set
{
text = value;
}
}


//protected override void Render(HtmlTextWriter writer)
protected override void RenderWebPart(HtmlTextWriter writer)
{
// TODO: add custom rendering code here.
// writer.Write("Output HTML");
RenderChildren(writer);
// Securely write out HTML
writer.Write("<BR>Text Property: " + SPEncode.HtmlEncode(Text));

}
}
}

To register a Web Part assembly as a SafeControl

When following the WebPart Library template instructions there are several options for ensuring the control is seen by WSS 3.0 as "safe". I initially edited the web.config in the root c:\inetpub\wwwroot directory - as it says in the instructions. When I imported the web part the import was successful (it showed up as an option on the import page), but dropping the webpart on the web part page failed with the message:

"Unable to add selected web part(s). A Web Part or Web Form Control on this Page cannot be displayed or imported. The type is not registered as safe." Here's a good description of how to make a control "safe" in Sharepoint's eyes. http://msdn2.microsoft.com/en-us/library/ms916848.aspx

So, I edited the web.Config at the root of my site, C:\Inetpub\wwwroot\wss\VirtualDirectories\5219, for example using the XML provided in the example:

<SafeControl
Assembly="SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def148956c61a16b" Namespace="MyWebParts"
TypeName="*" Safe="True" />

.... repeated the import and was then able to drop the web part on the webpart page. IT WORKED! And I could use it to change the 'Title" of the Web Part itself. Cool!

There are likely some elements of the file (above), for example in the "using" directives, that may not be quite kosher for WSS 3.0. I'm new to web parts and WSS 3.0 so I do not know (yet) what these are.

I hope this helps.

Tags What's this?: Add a tag
Flag as ContentBug
Inconsistencies in the article - IS there an actual web part library template for VS.NET 2005?      Mark Vogt   |   Edit   |   Show History

This article appears to have been written without actually being tried. How very very frustrating for those of us trying to find facts about web part development in Sharepoint 2007 with VS.NET 2005...

STRANGE:
The article states there is a web part library template for VS.NET2005, yet does not provide the URL to it. Even as of March 2007, I've tried by all means to find such a template, and without success. Apparently it's one of Microsoft's best-kept secrets. Every other article I've ever read online states there is NO such template for VS.NET 2005, and offers suggestions on how to make one using GAT and GAX.

ODD:
The article hints that it's about web parts in Sharepoint 2007 using VS.NET2005, yet it references deploying a web part build to /wwwroot/bin, which is a reference to what is clearly a Sharepoint 2003 production environment - not Sharepoint 2007, where there would be a distinct "/80/bin" directory or the like.

Finally, there is no DATE on the article - so it's challenging/impossible to determine the context in which the author wrote it.

Let's hope whoever at MSDN wrote it in the first place actually re-submits to some sort of editorial process that would have / should have trapped such inconsistencies, and dealt with them in a manner that helps would-be web part developers instead of further confusing them...

- MV

Tags What's this?: Add a tag
Flag as ContentBug
how about VB.net??      JaYZhiE ... Thomas Lee   |   Edit   |   Show History

I tried recreating above posts in VB. And I'm not seeing my web part on "new webpart page".

any ideas?

Tags What's this?: Add a tag
Flag as ContentBug
Agreed revision necessary      ted.phelps   |   Edit   |   Show History
This does not match the content in the free training for Sharepoint 3.0 (e-learning class 5045). I could not get either to work properly.
Tags What's this?: Add a tag
Flag as ContentBug
Is there an update to this article that is correct?      Cobom   |   Edit   |   Show History

Being a new user to sharepoint, as well as a new C# / visual studio enthusiest I find this article more frustrating than helpful. Following the steps:

To create a new Web Part Library project
1. Start Visual Studio.

2. On the File menu, point to New, and then click Project.

3. In the New Project dialog box, click Visual C# Projects, and then select the Web Part Library template.

Do not work - maybe because the non existant "using the Web Part Library template in Microsoft Visual Studio 2005. The Web Part templates can be downloaded from MSDN". If anybody finds these please let me know.

I understand that there may be some work on the end user while following on-line tutorials, it can be expected as part of the learning process - but do not make the new users fail right out of the box - especially with something as complicated as programming. New programmers require a lot of "hey that's cool", and "hey, that's not too hard to do" - before deciphering unusable tutorials found on the MSDN site.

I can imagine that anyone used to creating web part on vis studio.net for 2003 might not see my frustration - and maybe users more advance say "we don't use templates anymore - or something like that" - but when you follow thread after thread - especially those found on MS pages leading to template that do not exist........

Colin

Tags What's this?: Add a tag
Flag as ContentBug
Ask and Ye Shall Receive      Lord Bounty   |   Edit   |   Show History

And prepare to start regretting having ever asked as well.

Here is the link to Web Part Templates:
http://www.microsoft.com/downloads/details.aspx?familyid=19f21e5e-b715-4f0c-b959-8c6dcbdc1057&displaylang=en

NOTE: You must be running SPS 3.0 AND VS2005 AND Server 2003 or better to install this. Somewhere (I can't find it again) I found an .msi that allows you to bypass these requirements.

You'll find the Microsoft.Sharepoint.dll in your iss/istapi tree, but I've never managed to get it to work. I worked around that somehow. Again, don't ask how, I've ran about 12 different patches, upgrades and add-ons in every order I can think of, and at some point, it just stopped giving me buid errors.

And finally, it's only for C#, no VB support on this one.

Tags What's this?: Add a tag
Flag as ContentBug
developing on a server?      ekkis   |   Edit   |   Show History

> NOTE: You must be running SPS 3.0 AND VS2005 AND Server 2003

the install of these VS05 extensions for SPS seems to require the Sharepoint Services to be running on the same box... of course, that means I need a server class machine since SPS will not run on an XP workstation. so, essentially, I need to do development on a server???

I fail to understand the logic of this. anyone out there with a clue?

Tags What's this?: Add a tag
Flag as ContentBug
developing on a server - in a VPC      austegard   |   Edit   |   Show History
ekkis:
In order to do SharePoint development, MS appears to have taken the stance that it's all VirtualPC or nothing. Which means you can develop for SP on a laptop, you just need ample RAM to run a 2003 instance with MOSS, SQL, and VS within a VPC.
While this is workable, it is not particularly fun or efficient; HOPEFULLY MS will see the light and create a developer edition of MOSS/WSS that can run on IIS7 (Vista).
Tags What's this?: Add a tag
Flag as ContentBug
Getting past it not being "safe" with Sharepoint 2007      AndyIPW   |   Edit   |   Show History

Sharepoint seems to create the 80 dir for port 80, the random port directory and place the DLL in all three locations with the wwwroot\bin included in this or certainly, the Northwind sample CAB does.

The DLL should be placed into the wwwroot\bin and then registered at that location with both web.config files in the virtual directories including the safe control entry. With DLL's in these bin directories, it would pick these up first and not work. You could opt for the 80 virtual directory instead but it needs to be registered with that location.

I also registered the dll in the wwwroot dir in the GAC but this should not then be necessary. The GAC did not get around this initially because if you deploy from a CAB like from the Northwind example, these are not updated on a recompile and all would have to be replaced. The project itself targets the wwwroot\bin.

Andrew

Tags What's this?: Add a tag
Flag as ContentBug
Alternative version      B.i.l.l.y   |   Edit   |   Show History

Does anyone have any links that steps you though creating a Web Part ("hello world") for Sharepoint 2007?

bILLY

Tags What's this?: Add a tag
Flag as ContentBug
Web Part Template for non Server 2003 Machines?      esoto   |   Edit   |   Show History
Has anyone heard if there will be a version of the VS2005 Web Part Templates released for non Server 2003 machines? So far I've been able to develop with out them, but I imagine they would make development a little easier. Thanks! --Eric
Tags What's this?: Add a tag
Flag as ContentBug
Web Part Templates      antero   |   Edit   |   Show History

I found Web Part Templates for VS2005 beyond this link: http://www.gotdotnet.com/workspaces/workspace.aspx?id=291c3164-d28e-45ee-b982-46b7bd472033

It still won't remove that fact, that walk-through above doesn't work for me. I can upload Web Part in SP, but when I try to drag it to the Web Part Page, I just get trivial errormessage which says me nothing.

Tags What's this?: Add a tag
Flag as ContentBug
Not Rendering      Eider Mauricio Aristizabal Erazo   |   Edit   |   Show History

Hi All,
I guess that that article is good, I made it work but was very hard to make it, I agree with Mr. Cobom this is not esay for newer programmers.
My point is next, Exist any form to create the web controls as the same manner like standard web form pages are created?, I mean dragging and dropping web controls with not having to create it manually by code. I'm creating a big project on SharePoint and this is not an adventage. Try creating Tables to organize your web controls and giving them for to increase the look and Feel... that task take a lot of time so I'm very dissapointed, I have not found any manner and the time is going to the end.

Best Regards,

Hola a todos,
Pienso que el articulo es bueno, lo hice funcionar pero fue muy dificil, Estoy de acuerdo con el señor Cobon, esto no es facil para los programadores nuevos.
Mi punto es el siguiente, Existe alguna forma para crear webcontrols de la misma manera que se crean los webforms estándar, es decir arrastrando y soltando webcontrols sin tener que crearlos manualmente por codigo. Estoy creando un gran proyecto en SharePoint y esto no es una ventaja. Intenta crear tablas para organizar sus WebControls para mejorar el Look And Fell... Esa tarea toma mucho tiempo, entonces estoy muy decepcionado, No he encontrado alguna manera y el timempo esta llegando a su fin.

Salu2 desde Colombia.

eidermauricio@hotmail.com

Flag as ContentBug
Get started making your own "Business Data      Chris H E   |   Edit   |   Show History

This is specifically addressed to the question that Eider Mauricio posed about a way to use "dragging and dropping..."

I found that I can create a web part in Visual C# 2005 Express then add a reference to it in Visual Web Developer 2005 Express and drag and drop it to a form there and test it. Then I can put the .dll in the windows/assembly folder on my sharepoint box and add it as a web part to my sharepoint sites.

What this web part does is very simple, just accesses some data on our IBM iSeries (AS/400) DB2 database and displays it in the web part, as an example. What I'll do later is add the code to have it provide the data to other web parts when they are connected. Much thanks for his example (Another webparts sample) on carlosag.net to Carlos Aguilar Mares, see this and it will help you. "Que te ajudo mucho mijo!" (mi esposa de 12 anos es una Colombiana (Valluno/Tuluena))

When you deploy your web part, make sure you have installed your data provider on the server where sharepoint is running or this won't work. For me, that's IBM client access V5R4 .net DB2 provider, which is not selected in the basic install, make sure you go to custom install and select it!

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;

namespace MyWebParts
{
public class My2ndWebPart : WebPart
{

GridView _view;

public My2ndWebPart()
{

}


protected override void CreateChildControls()
{
_view = new GridView();
_view.AutoGenerateColumns = true;
CommandField field = new CommandField();
field.ShowSelectButton = true;
_view.Columns.Add(field);

SqlDataSource ds = new SqlDataSource();
ds.ID = "_authorsDS";
ds.ConnectionString = "Provider=IBMDA400.DataSource.1;Data Source=servername;Password=mypassword;User ID=myuserid;Initial Catalog=catalogname";
ds.ProviderName = "System.Data.OleDb";

ds.SelectCommand = "select arno01, arnm01 from hd1100pd.arlmcus1 where arno01 = 123522";
_view.DataSourceID = ds.ID;

this.Controls.Add(ds);
this.Controls.Add(_view);

base.CreateChildControls();

}

}
}

Enjoy!

Chris Eidsmoe.

Tags What's this?: Add a tag
Flag as ContentBug
Alternate Version      Jade Skaggs   |   Edit   |   Show History
I found this article to be quite easy to build. I didn't follow it to the 'T', but I also have a little experience building webparts. For the beginners, try the Microsoft screencasts:
http://msdn2.microsoft.com/en-us/office/aa905382.aspx

or more specifically, this video:
http://download.microsoft.com/download/a/6/1/a61dd5df-f52c-42d5-a95c-7a7fb7a6a466/AspWebPartsForWss3.wmv

This will get you up and running with a 'hello world' like project.

Regards,

Jade Skaggs
Tags What's this?: Add a tag
Flag as ContentBug
Web parts didn't work      Terri N ... Stanley Roark   |   Edit   |   Show History
Hi,

I am new with Sharepoint. I have done all the instructions in this article and I was able to upload the web part. But when I tried to import the web part, I got a warning which says Unable to add selected web part(s). Cannot import this web part.

Can some one help? Thanks.

Regards,

Terri

Terri - rather than asking here, why not visit on-line SharePoint forums such as: http://www.sharepointforums.com/, http://www.sharepointforums.com/ or the MSDN forums you can reach by clicking on Support above?


May be useful      Z.Edrissi   |   Edit   |   Show History
Hi,
After placing your assembly to the GAC, you should add your webpart to the safe control list by adding a safe control entry for your custom assembly to the web.config file as follow:
[XML]
<SafeControl Assembly="dll name", version=1.0.0.0, Culture=neutral, PublicKeyToken=Replace it here form GAC" NameSpace="name space" TypeName="*" Safe="True" AllowRemoteDesigner="True"/>

After you have deployed your web part and registered it in the safe control , navigate to http://MyServer/_layouts/newdwp.aspx, where MyServer is the name of the server on which your sharepoint site is deployed.
Select the check boc next to MyNameSpace.MyClassName and then click PopulateGallery Button to add your web part in Gallery webpart.

for more information you can navigate to http://msdn.microsoft.com/en-us/library/ms415817.aspx

regards,
edrissi
Tags What's this?: Add a tag
Flag as ContentBug
VB vs. C#      TheEdiot   |   Edit   |   Show History

All of the examples I've tried from Microsoft and other sources only produce errors if the source is VB. This includes adding to galleries and page importing.

After 2 days of @#$% around, I stumbled on a blog entry that indicated a fellow could only get C# projects to function.

Lo and behold - it was the truth.

ABSOLUTELY BUSH LEAGE MARKETECHTURE EXAMPLES FOR DEVELOPERS FROM MICROSOFT!!!!


Thanks for pissing away 2+ days on untried guideance....

Tags What's this?: Add a tag
Flag as ContentBug
VisualStudio Add-In for Web Parts generation      Sasa Popovic   |   Edit   |   Show History
Check this step-by-step tutorial that shows how you can create a template as regular ASCX control and then use a VisualStudio Add-In to generate a web part based on that template: http://www.codeproject.com/KB/sharepoint/webparts_generator_addin.aspx

Add-In and related assemblies are hosted on codeplex: http://www.codeplex.com/aspnetlibrary
Sharepoint Webparts      Ramprasad N   |   Edit   |   Show History
Flag as ContentBug
Create Simple Web Part for SharePoint 2007      Ahmed Abu Dagga   |   Edit   |   Show History
I beleive you need a Windows 2003 Server machine with SharePoint and Visual Studio 2005      David G. Ghikas   |   Edit   |   Show History
I believe you need to develop your SharePoint webparts on a Windows 2003 Server machine with SharePoint and Visual Studio 2005 installed. One may think that you can develop the solution on a XP or Vista machine and then deploy to a Windows SharePoint Server but this is not the case.
Minor Fix required to get this Working...      Boris Momtchev   |   Edit   |   Show History
Well, simply make sure your namespace is correct !!
If follow this article closely you Will end up with a namespace = "MyWebParts" in both your Web.config AND your *.dwp file...
But while building the DLL your namespace may default to: "SimpleWebPart"

So, if that is your case: one way to fix this is to change your *.dwp and Web.config as specified below:

<?xml version="1.0"?>
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
<Assembly>SimpleWebPart, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=YourPublicKeyToken</Assembly>
<TypeName>SimpleWebPart.SimpleWebPart</TypeName>
<Title>My Simple Web Part</Title>
<Description>A simple Web Part</Description>
</WebPart>

And then in the Web.conig...

<SafeControl Assembly="SimpleWebPart, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=YourPublicKeyToken"
Namespace="SimpleWebPart" TypeName="SimpleWebPart" Safe="True"/>



Restart IIS just in case!
It worked for me...
Tags What's this?: fixed (x) Add a tag
Flag as ContentBug
SharePoint Development      sarangasl   |   Edit   |   Show History

Try this,

http://sarangasl.blogspot.com/search/label/SharePoint
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker