SharePoint项目删除evert不起作用

发布于 2024-09-02 21:43:42 字数 884 浏览 8 评论 0原文

我在 SharePoint 中有一个网站,我想从列表中自定义删除。因此,我正在创建

 public class ListItemEventReceiver : SPItemEventReceiver
 {
 public override void ItemDeleting(SPItemEventProperties properties)
        {
            if (properties.ListTitle.Equals("Projects List"))
            {
               Projects pr = new Projects();
               string projectName = properties.ListItem["Project Name"].ToString();
               pr.DeleteProject(projectName);
            }
         }
}

“Projects”类具有删除项目的“DeleteProject”方法。 但它什么也没做:( 我提到,Feature.xml 中一切正常,

我哪里错了?

编辑(来自“答案”):

  1. 是的,我已经尝试过:

    properties.ErrorMessage = "项目名称:" + 项目名称;
    属性.取消= true; 
    

    在 if 子句和它触发的事件中并正确显示项目名称。是

  2. 我是场管理员和网站管理员,可以完全控制此网站。

  3. DeleteProject 方法是正确的,因为我已经在其他一些应用程序(c#)中尝试过它并且工作正常。

I have a site in SharePoint and I want to custom delete from a list. So, I'm creating the

 public class ListItemEventReceiver : SPItemEventReceiver
 {
 public override void ItemDeleting(SPItemEventProperties properties)
        {
            if (properties.ListTitle.Equals("Projects List"))
            {
               Projects pr = new Projects();
               string projectName = properties.ListItem["Project Name"].ToString();
               pr.DeleteProject(projectName);
            }
         }
}

Where 'Projects' class has 'DeleteProject' method who deletes the item.
But it's doing nothing :(
I mention that everything it's ok in Feature.xml

Where am I wrong?

Edit (from 'answer'):

  1. Yes, I've tried this:

    properties.ErrorMessage = "projectName :" + projectName;
    properties.Cancel = true; 
    

    in if clause and the event it's firing and displays the project name corectly.

  2. I'm the farm administrator, and site administrator with full control over this site.

  3. DeleteProject method it's right, because I've tried it in some other application (c#) and it's works fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撑一把青伞 2024-09-09 21:43:42

有几件事需要检查:

  • 您的列表项接收器是否已连接到列表,以便它触发?
  • 触发触发器的用户是否有权删除项目?
  • 请问DeleteProject有什么编程错误吗?

尝试添加一些日志记录以查看它运行了多远。

编辑

问题可能出在这里:

           string projectName = properties.ListItem["Project Name"].ToString(); 

名为“项目名称”的列表项名称中是否有空格?

编辑2

根据您的评论,身份验证和连接字符串的组合意味着它是针对数据库使用的登录用户的安全上下文。检查您的用户的权限。

A couple of things to check:

  • Is your list item reciever connected to the list, so that it fires?
  • Does the user that causes the trigger to fire have the the right to delete items?
  • Is there any programming error in DeleteProject?

Try putting in some logging to see how far it is running.

Edit

Could the problem be here:

           string projectName = properties.ListItem["Project Name"].ToString(); 

Is the list item called "Project Name" with a space in the name?

Edit 2

From your comments, the combination of authentication and connection string means that it is the security context of the logged on user that is being used against the database. Check the rights of your user.

旧瑾黎汐 2024-09-09 21:43:42

如果事件正在触发并且唯一的方法 pr.DeleteProject(projectName);如果工作不正常,那么很难猜测出了什么问题。如果不是保密的,请发布您的代码,然后我将能够更好地找出问题所在。

顺便问一下,您是否在列表上调用 .Update() 方法?

请查看此链接 http://msdn.microsoft.com/en-us /library/ms431920.aspx

另一件需要关心的事情是 Itemed 和 Iteming 事件。对于 Item*ing 事件,最好根据情况使用 Before 或 After 属性。

问候,

阿泽尔·伊克巴尔

If event is firing and the only method pr.DeleteProject(projectName); is not working properly then it is difficult to guess what is wrong. If it is not confidential, please post your code and then I shall be in better position to identify what is wrong.

By the way, are you calling .Update() Method on list?

Please check out this link http://msdn.microsoft.com/en-us/library/ms431920.aspx

One more thing to care about is Itemed and Iteming events. It is better to use Before or After properties as appropriate in case of Item*ing events.

Regards,

Azher Iqbal

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文