Comments events
This section provides you with an overview of the comment events that use the Telerik.Sitefinity.Services.Comments assembly.
All content modules support comments that expose their own set of events. You can use these events to execute your own logic whenever an action on a comment is performed. This logic is executed for all modules, which support comments. The type of the items, which are commented, is passed as an argument to your event handler. With the rest of the events, you must always use interfaces to subscribe, even if the actual events that fire are concrete implementations (classes).
Following is a full list of the events supported by comments:
ICommentEvent
This interface is implemented by all events fired for Comments. Use it, if you want to subscribe to all of them.
Subscribe using the following code:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ICommentEvent>(evt => CommentsEventHandler(evt));
}
public void CommentsEventHandler(ICommentEvent eventInfo)
{
var item = eventInfo.Item;
}
}
}
For more information, see For developers: Comments module.
ICommentCreatingEvent
This interface is implemented by all events that fire before a comment is created. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ICommentCreatingEvent>(evt => CreatingCommentsEventHandler(evt));
}
public void CreatingCommentsEventHandler(ICommentCreatingEvent eventInfo)
{
// your logic
}
}
}
ICommentCreatedEvent
This interface is implemented by all events that fire after a comment has been created. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ICommentCreatedEvent>(evt => CreatedCommentsEventHandler(evt));
}
public void CreatedCommentsEventHandler(ICommentCreatedEvent eventInfo)
{
// your logic
}
}
}
ICommentUpdatingEvent
This interface is implemented by all events that fire before a comment is updated.
Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ICommentUpdatingEvent>(evt => UpdatingCommentsEventHandler(evt));
}
public void UpdatingCommentsEventHandler(ICommentUpdatingEvent eventInfo)
{
var originalItem = eventInfo.OriginalItem;
}
}
}
In the event handler you can access the original comment item.
ICommentUpdatedEvent
This interface is implemented by all events that fire after a comment is updated.
Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ICommentUpdatedEvent>(evt => UpdatedCommentsEventHandler(evt));
}
public void UpdatedCommentsEventHandler(ICommentUpdatedEvent eventInfo)
{
// your logic
}
}
}
ICommentDeletingEvent
This interface is implemented by all events that fire before a comment is deleted.
Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ICommentDeletingEvent>(evt => DeletingCommentsEventHandler(evt));
}
public void DeletingCommentsEventHandler(ICommentDeletingEvent eventInfo)
{
// your logic
}
}
}
ICommentDeletedEvent
This interface is implemented by all events that fire after a comment has been deleted. Use the following code to subscribe:
using System;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Services.Comments;
namespace SitefinityWebApp
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}
private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
EventHub.Subscribe<ICommentDeletedEvent>(evt => DeletedCommentsEventHandler(evt));
}
public void DeletedCommentsEventHandler(ICommentDeletedEvent eventInfo)
{
// your logic
}
}
}