A long time ago (beta2 time) I published a post about the people picker control (MOSS 2007 controls - have a bit of fun with the "people editor" form control!).
Lately I had many comments on that post from people who have been having issues getting the value the user selected, and asked for another demo of using the control.
So here it is:
The code creates three controls - a PeopleEditor (from the Microsoft.SharePoint.WebControls namespace), a button and a textbox. The button has an click event that itirates over the users picked in the PeopleEditor and writes them to the text box. Simple!
public class PeoplePickerWebPart : System.Web.UI.WebControls.WebParts.WebPart
protected override void CreateChildControls()
pe = new PeopleEditor();
b = new Button();
b.Text = "Click me to see the users";
b.Click += new EventHandler(b_Click);
t = new TextBox();
t.TextMode = TextBoxMode.MultiLine;
void b_Click(object sender, EventArgs e)
foreach(string ent in pe.CommaSeparatedAccounts.Split(','))
t.Text += ent + Environment.NewLine;