1

I have created the SharePoint custom list.i need to give the "Contribute" access for visitor. how to handle this by using c#. Suggest any idea to implement this.

2

Try below code:

SPList customList = web.Lists.TryGetList("CustomList");
if (!customList.HasUniqueRoleAssignments)
{
    customList.BreakRoleInheritance(false, false);
}
customList.Update();
web.Update(); 

SPRoleAssignment roleAssignment = new SPRoleAssignment((SPPrincipal)web.SiteGroups["VisitorGroupName"]);

roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions.GetByType(SPRoleType.Contributor));

customList.RoleAssignments.Add(roleAssignment);

customList.Update();

web.Update();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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