Welcome to Comunidade Bloggers |create|it| Sign in | Join | Help

André Vala

SharePoint
Office
FAST Search Server
.Net

News

  • European SharePoint Community Awards 2012 Winner
    Locations of visitors to this page

    Comunidade Portuguesa de SharePoint

    View André Vala's profile on LinkedIn

    © André Vala and Create IT, 2006-2011. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to André Vala and Create IT with appropriate and specific direction to the original content.

SharePoint Tip #9: Utilizar o DisableEventFiring() e o EnableEventFiring()

Num event handler de um lista é frequente haver a necessidade de actualizar um item recorrendo ao método Update() da classe SPListItem. Quando este método é chamado são disparados dois novos eventos, ItemUpdating e ItemUpdated. É fácil perceber que, se o event handler em causa for para um destes eventos, o facto de provocar o disparo dos eventos vai levar a que se entre num ciclo potencialmente infinito (não o é porque o SharePoint acaba por interrompê-lo).

Solução: para evitar esta situação podemos chamar o método DisableEventFiring() no início do event handler, e o método EnableEventFiring() no final do mesmo, fazendo com que não sejam disparados novos eventos mesmo que se chame o método Update() do item.

Posted: Saturday, January 06, 2007 6:04 PM by andrevala

Comments

No Comments

Anonymous comments are disabled