Tuesday, 24 December 2013

People Picker control

People Picker control below User Interface :


Add below CSS
 .ms-inputuserfield
{
font-size: 8pt;
font-family: Verdana,sans-serif;
border: 1px solid #a5a5a5;
}
div.ms-inputuserfield a
{
color: #000000;
text-decoration: none;
font-weight: normal;
font-style: normal;
}
div.ms-inputuserfield
{
padding-left: 1px;
padding-top: 2px;
}




Ascx controlCoding :à

<SharePoint:PeopleEditor ID="peopleEditorRelegationDetailsSharedBy" runat="server"
AllowEmpty="true" SelectionSet="User" Width="400px" MultiSelect="false" validationgroup="Tr"
ValidatorEnabled="true" BorderColor="Black" BorderWidth="0px" />


.cs Coding :à
if (peopleEditorRelegationDetailsSharedBy.ResolvedEntities.Count> 0)
                 {
peopleEditorRelegationDetailsSharedBy.Validate();

if (peopleEditorRelegationDetailsSharedBy.IsValid)
                     {
RelegationDetailsSharedBy = peoplePickerData();
peoplepickervalue = true;
                     }                 

                 }
else
                 {
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Msg", "alert('There are no recipients in Relegation Details SharedBy by')", true);
                 }



public string peoplePickerData()
        {
            #region Relegated By People Picker
stringSharedBy = string.Empty;
stringSharedByEmail = "";
if (peopleEditorRelegationDetailsSharedBy.Entities.Count> 0)
            {
for (inti = 0; i<peopleEditorRelegationDetailsSharedBy.ResolvedEntities.Count; i++)
                {
PickerEntity picker = (PickerEntity)peopleEditorRelegationDetailsSharedBy.ResolvedEntities[i];
if (peopleEditorRelegationDetailsSharedBy.Accounts[i].ToString().Contains("GOINDIGO"))
                    {
if (SharedBy == string.Empty)
SharedBy = peopleEditorRelegationDetailsSharedBy.Accounts[i].ToString().Split('\\')[1];
else
SharedBy = SharedBy + "," + peopleEditorRelegationDetailsSharedBy.Accounts[i].ToString().Split('\\')[1];
                    }                  
Hashtable hash = picker.EntityData;
stringstrRecEmail = Convert.ToString(hash["Email"]);
SharedByEmail += strRecEmail;
                }
            }
returnSharedByEmail;
            #endregion
        }

No comments:

Post a Comment