毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 企业开发 >> 正文

sharepint2010如何处理列表Create事件

更新时间:2014-1-26:  来源:毕业论文

有sharepint用代码实现权限管控的问题,有哪位大侠帮忙看看下面的代码在VS中如何操作:

一旦提交申请,就只有本人、审批人、管理员可以看到。而且审批人有“批准”权限。
为实现这个功能,需要处理列表的 Create 事件。
先断开现有的继承权限。

item.BreakRoleInheritance(false);


然后,绑定新的权限。
protected void bind_role(SPListItem item, SPPrincipal principal, SPRoleDefinition definition)
{
    try
    {
        SPRoleAssignment assignment = new SPRoleAssignment(principal);
        assignment.RoleDefinitionBindings.Add(definition);
        item.RoleAssignments.Add(assignment);
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

对某个用户执行绑定角色的操作。
bind_role(item, user, web.RoleDefinitions["参与讨论"]);
Eventhandler
ItemAdded

1.Start Microsoft Visual Studio 2010.

2.On the File menu, point to New, and then click Project.

3.In Project Types, under Visual Basic or C#, select Event Receiver.

4.Type DeletingEventReceiver as the project name. Click OK.

5.In the SharePoint Customization Wizard, choose Deploy as a sandboxed solution. Click Next.

6.In the Choose Event Receiver Settings dialog, select List Item Events in the What type of event receiver do you want? dropdown.

7.In the What item should be the event source? dropdown, choose Tasks.

8.Choose the An item is being deleted option in the Handle the following events list. Click Finish.

9.In the EventReceiver1 file that is created, insert the following code in the ItemDeleting method.

 properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = "Deleting items from " + properties.RelativeWebUrl + " is not supported.";

10.Press F5 to deploy the solution.

11.Navigate to a task list and select an item in the list. Click the Delete Item button on the Server ribbon.

12.Observe the error message.

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。