showentitydisplaytextintextbox="true" validatorenabled="true">
protected void AddUserBtn_Click(object sender, EventArgs e)
{
try
{
if (userPPE.ResolvedEntities.Count > 0)
{
PickerEntity tempEntity = ((PickerEntity)userPPE.ResolvedEntities[0]);
string userID = tempEntity.Key;
string userEmailID = string.Empty;
string userName = string.Empty;
if (tempEntity.EntityData["Email"] != null)
{
userEmailID = tempEntity.EntityData["Email"].ToString();
}
if (tempEntity.EntityData["Name"] != null)
{
userName = tempEntity.EntityData["Name"].ToString();
}
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWeb web = SPContext.Current.Web;
web.Groups["UsersGroup"].AddUser(userID, userEmailID, userName, "");
msgLbl.Text = "User added successfully to the UsersGroups....";
});
}
}
catch (Exception ex)
{
msgLbl.Text = ExceptionMsg;
LogException.WriteToFile(System.DateTime.Now.ToString() + ex.Message + ex.Source.ToString() + ex.StackTrace.ToString());
}
}
------------------------------------------------------
Fill Users Group in DropDown
SPUserCollection grpMgrUsers = hulWeb.Groups["AO"].Users;
if (grpMgrUsers != null)
{
if (grpMgrUsers.Count > 0)
{
foreach (SPUser usr in grpMgrUsers)
{
if (string.Compare(usr.Name, "System Account", true) != 0)
{
basisProjMgrDDL.Items.Add(new ListItem(usr.Name, usr.LoginName));
}
}
}
-----------------------------------------------------
Redirect URL (Cancel)
public string RedirectURL()
{
if (Context.Request.QueryString["Source"] != "")
{
return Context.Request.QueryString["Source"];
}
return "/";
}
------------------------------------------------------
-------------------------------------------------------------