Saturday, January 4, 2014

Get Set Value in PeopleEditor Webpart in Visual Webpart

Adding to Webpart

<SharePoint:PeopleEditor ID="myPeoplePicker" runat="server" Width="300" BorderStyle="Solid" BorderColor="Black" BorderWidth="1" />


Reading Value from Control

if(myPeoplePicker.ResolvedEntities.Count >0 )
{
PickerEntity objEntity = (PickerEntity) myPeoplePicker.ResolvedEntities[0];
    SPUserInfo objInfo = new SPUserInfo();
    objInfo.LoginName = objEntity.Key;
    strAccountName = objInfo.LoginName;

//objEntity.EntityData Gets or sets a data-mapping structure that is defined by the consumer of the PickerEntity class. This properties has all data related to user entity.

}

Setting Value to Control

myPeoplePicker.CommaSeparatedAccounts = "domain\username";
myPeoplePicker.ValidateEntity()


Hope this helps...Happy Coding!!!

No comments:

Post a Comment