在sharepoint的文档库中,我想实现在下拉菜单中新建一个选项—“锁定”,主要功能是实现点击锁定后收回该文档的权限,使任何人都没有查看编辑该文档的权限。我新建了一个空元素和一个类,类的功能是控制权限,并用空元素中的xml去调用这个类。
空元素:Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id = "0x0101004de98b4273484499bd03932084e617e0"
Location = "EditControlBlock"
RegistrationId = "101"
RegistrationType = "List"
Sequence = "1000"
Title = "锁定2"
>
<UrlAction Url="javascript:__doPostBack('MyEventTarget','itemid={ItemId}{ListId}')"/>
</CustomAction>
<CustomAction
Id="UserInterfaceCustomActions.SiteActionsToolbar"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="MY SITE ACTIONS BUTTON"
ControlAssembly="ZHFD_DEPART_WorkLog,Version=1.0.0.0,Culture=neutral,PublicKeyToken=95d4eedb01a256e5"
ControlClass="ZHFD_DEPART_WorkLog.actioncontrols">
</CustomAction>
</Elements>
actioncontrols.cs:
namespace ZHFD_DEPART_WorkLog
{
public class actioncontrols:SPLinkButton
{
protected override void OnLoad(EventArgs e)
{
if (this.Page.Request["__EVENTTARGET"] == "MyEventTarget")
{
string ListAndItemId = this.Page.Request["__EVENTARGUMENT"].ToString();
int ItemLenBeg = ListAndItemId.IndexOf("=") + 1;
int ListLenBeg = ListAndItemId.IndexOf("{");
int ListLenEnd = ListAndItemId.IndexOf("}") + 1;
string ItemId = ListAndItemId.Substring(ItemLenBeg, ListLenBeg - ItemLenBeg);
string ListId = ListAndItemId.Substring(ListLenBeg, ListLenEnd - ListLenBeg);
Guid listId = new Guid(ListId);
int itemId = Convert.ToInt32(ItemId);
SPWeb myweb = SPContext.Current.Web;
SPList loglist = myweb.Lists[listId];
foreach (SPListItem getitem in loglist.Items)
{
if (getitem.ID == itemId)
{
//移除权限
RemoveRoles(getitem);
}
}
}
}
}
}
现在的问题是Elements.xml无法调用到actioncontrols.cs,请大家帮帮忙,替我找找原因,谢谢了
在webconfig中把ControlAssembly="ZHFD_DEPART_WorkLog,Version=1.0.0.0,Culture=neutral,PublicKeyToken=95d4eedb01a256e5"
ControlClass="ZHFD_DEPART_WorkLog.actioncontrols"
设为信任控件即可。