0

I am using the below code in my application page to get the the Display name from people picker. but it is returning as null can you please help me in this regard.

However if i use SPUSER object iam able to get the USername. Commented code in the below method. Note: I was able to fetch the Email with out using the spuserobject.

for (int i = 0; i < userPicker.ResolvedEntities.Count; i++)
                {
                    PickerEntity picker = (PickerEntity)userPicker.ResolvedEntities[i];
                    //string username = picker.Description;
                    //SPUser user = mySiteWeb.EnsureUser(username);

                    //string displayname = user.Name;
                    Hashtable hstEntityData = picker.EntityData;
                    string emailID = Convert.ToString(hstEntityData["Email"]);
                    String DisplayName = Convert.ToString(hstEntityData["DisplayName"]);
                    Emailarray.Add(emailID);
                }

2 Answers 2

1

Kindly have a try with the below code to get the display name using Javascript from the client side:

var user = $("span.ms-entity-resolved").attr("title");

Here user is the variable which will have the display name in text format.

0

How about using the email to resolve your SPUser object?

See this stack exchange question

Add Domain User To The Site With Having Only Email Address

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.