Hello World Web Part Class Example

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

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace HelloWorldWebPart
{
[Guid(“dcd75a9a-b5b2-4e09-b658-65d40d989958”)]
public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
private string displayText = “Hello World!”;
[WebBrowsable(true), Personalizable(true)]
public string DisplayText
{
get { return displayText; }
set { displayText = value; }
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
writer.Write(displayText);
}
}

}

Dropdown to change the view disappeared on list web part

When you go to a document library or list in Sharepoint 2007, you see a dropdown in which you can select a different view or create a new view if you have the right permissions.

If you ever find yourself thinking “Where did the change the view dropdown go?”

Don’t worry, one of two things could have happened.You added a second document library webpart on your page, but this would be obvious because you would see two webparts, one with a dropdown and one without it.Your user (or yourself) -closed- the webpart and added it again, leaving the closed webpart on the page, but hidden. This one is harder to detect, because you only see the webpart without the dropdown.

How do you fix this?
In the first case there isn’t much of a problem, you -delete- the second webpart from the page or you leave it on there (but without the dropdown).
For the second case you’ll have to edit the page (Site Actions, Edit Page), press Add a Web Part. At the bottom of the dialog is a link “Advanced Web Part gallery and options“, click it. A side bar “Add Web Parts” appears. Below the “Select the collection you want to browse.” is a link called “Closed Web Parts“, when you click it the Web Part List with closed Web Parts appears. Select the Document Library Web Part and click the “Add” button on the bottom of the screen. The page will show the two Web Parts, -delete- the one without the dropdown and you’re back in business.
Why? A web part which shows a list is supposed to display only one view of the list at a time. But you can definitely change the view by modifying the shared web part properties.

Dropdown to change the view disappeared on list web part

When you go to a document library or list in Sharepoint 2007, you see a dropdown in which you can select a different view or create a new view if you have the right permissions.

If you ever find yourself thinking “Where did the change the view dropdown go?”

Don’t worry, one of two things could have happened.You added a second document library webpart on your page, but this would be obvious because you would see two webparts, one with a dropdown and one without it.Your user (or yourself) -closed- the webpart and added it again, leaving the closed webpart on the page, but hidden. This one is harder to detect, because you only see the webpart without the dropdown.

How do you fix this?
In the first case there isn’t much of a problem, you -delete- the second webpart from the page or you leave it on there (but without the dropdown).
For the second case you’ll have to edit the page (Site Actions, Edit Page), press Add a Web Part. At the bottom of the dialog is a link “Advanced Web Part gallery and options“, click it. A side bar “Add Web Parts” appears. Below the “Select the collection you want to browse.” is a link called “Closed Web Parts“, when you click it the Web Part List with closed Web Parts appears. Select the Document Library Web Part and click the “Add” button on the bottom of the screen. The page will show the two Web Parts, -delete- the one without the dropdown and you’re back in business.
Why? A web part which shows a list is supposed to display only one view of the list at a time. But you can definitely change the view by modifying the shared web part properties.