Sunday, December 31, 2017

Postback Event when using SharePoint PeopleEditor

Postback Event when using SharePoint PeopleEditor


Im using the SharePoint PeopleEditor to select a user and when the user is selected I want to populate a few fields with information about that user, I get the data from a Database. The problem is, how to make the PeopleEditor send a signal to my code that a value has been set?! There is no event on the PeopleEditor control fires when a value is set.

few minuites of googling lead me to msdn   this article  ,
When you set the property AutoPostBack to true,  a Postback will be generated when a value is set in the control.

In the case of the PeopleEditor this means that when you type a username and click Check names (or hit enter) or use the Addressbook to select a user you will receive a generic postback, and the page is reloaded. There you can have a code in Page_Load that checks if a value has been selected and take some action like querying that database with the PeopleEditor user as a key and then filling other controls on the page.

string accountName = null;

if(peUser.ResolvedEntities.Count > 0)

 {

      PickerEntity entity = (PickerEntity)peUser.ResolvedEntities[0];

accountName = entity.Key;

      int pos = accountName.IndexOf();

      accountName = accountName.Substring(pos + 1);


// take some action based on accountName



 } 



visit link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.