We often have a requirement such as to create a SharePoint Group and at the same time we need to add the name of this newly created security group in the Security Group quick launch.This can be done using the SharePoint User Interface like this:Likewise we can edit the SharePoint quick launch and add or remove the Security Groups from it.What if we have a requirement to edit it programmatically? Suppose we have a requirement to create a SharePoint Group programmatically and at the same time this newly created SharePoint Group needs to be added to the Security Group Quick Launch and removed from some other groups.The following is the code snippet which can be used to edit the Security Group Quick Launch.objSPweb.AssociatedGroups.Add() and objSPweb.AssociatedGroups.Remove() are the two methods which are used to edit the Security Group Quick launch.
/***************************************************************/ ///Edit Group Quick Launch /// using (SPSite objSPSite = new SPSite(SPContext.Current.Web.Url)) { using (SPWeb objSPweb = objSPSite.OpenWeb()) { objSPweb.AllowUnsafeUpdates = true; objSPweb.AssociatedGroups.Add(SPContext.Current.Web.Groups["Test Members"]); objSPweb.Update(); } }/***************************************************************/
In this way we can achieve this requirement.Hope it will be a help to you!
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: