Everything SharePoint and XAML

My continuous learning of SharePoint, XAML, Silverlight, Windows Phone 7, Windows 8, Office, VSTO, C#…

Three SharePoint Controls: InputFormTextBox, PeoplePicker, DateTimeControl

Posted by Steve Pietrek on January 9, 2009

The Microsoft.SharePoint.WebControls namespace provide many controls which you can use in web parts or layout pages within SharePoint. Three controls I used recently on a project include:

1. InputFormTextBox – The InputFormTextBox is a rich text editor that includes a toolbar for editing content within the textbox. An example of creating an InputFormTextBox can be found below.

public InputFormTextBox BuildInputFormTextBox(string id) {
InputFormTextBox iftb = new InputFormTextBox {
ID = id,
RichText = true,
RichTextMode = SPRichTextMode.Compatible,
TextMode = TextBoxMode.MultiLine,
Rows = 10,
Columns = 10
};
return iftb;
}

Update (Feb 24/2009): I have received many questions on how to expand an InputFormTextBox. Dario has a good post on the subject.

2. PeopleEditor – In many circles, it is also known as the SharePoint People Picker. It allows users to search and select users defined at a particular scope. An example of creating the PeopleEditor can be found below.

public PeopleEditor BuildPeopleEditor(string id, bool allowempty, bool multiselect) {
PeopleEditor pe = new PeopleEditor {
ID = id,
IsValid = true,
AllowEmpty = allowempty,
Width = Unit.Pixel(200),
AllowTypeIn = true,
MultiSelect = multiselect,
BackColor = Color.Cornsilk,
ValidatorEnabled = true
};
return pe;
}

An example of retrieving the first user can be found below.

public string RetrievePeopleEditorUser(EntityEditor pe) {
if (pe.Entities.Count > 0) {
PickerEntity entity = (PickerEntity)pe.Entities[0];
return entity.DisplayText;
}
return string.Empty;
}

3. DateTimeControl – The DateTimeControl is a user control which is simply a text box and calendar dropdown. An example of creating a DateTimeControl can be found below.

public DateTimeControl BuildDateTimeControl(string id) {
DateTimeControl dtc = new DateTimeControl {
ID = id,
DateOnly = true
};
return dtc;
}

Advertisements

One Response to “Three SharePoint Controls: InputFormTextBox, PeoplePicker, DateTimeControl”

  1. Thibaud said

    Hi,
    Are you able to change the width of the InputFormTextBox?

Sorry, the comment form is closed at this time.

 
%d bloggers like this: