There are two methods for deleting a post:
- DeletePost(IPost post) - Pass the post that will be deleted
- DeletePost(Guid postID) - Pass the ID of the post that will be deleted
Delete a specified post:
| DeletePost(IPost post) |
Copy Code |
|
// create new instance of ForumManager Telerik.Forums.ForumManager forumManager = new Telerik.Forums.ForumManager(); // get all forums IList listOfForums = forumManager.GetForums(false); if (listOfForums.Count > 0)
{
// get first forum
Telerik.Forums.IForum firstForum = (Telerik.Forums.IForum)listOfForums[0];
// get all posts for this forum with specified ID
IList listOfPosts = forumManager.GetForumThreads(firstForum, false);
// get first post of the list
Telerik.Forums.IPost thirdRootPost = forumManager.GetPost(((Telerik.Forums.IPost)listOfPosts[1]).ID);
// delete the post
forumManager.DeletePost(thirdRootPost);
}
|
Delete a post by specified ID:
| DeletePost(Guid postID) |
Copy Code |
|
// create new instance of ForumManager Telerik.Forums.ForumManager forumManager = new Telerik.Forums.ForumManager(); // get all forums IList listOfForums = forumManager.GetForums(false); if (listOfForums.Count > 0)
{
// get first forum
Telerik.Forums.IForum firstForum = (Telerik.Forums.IForum)listOfForums[0];
// get all posts for this forum with specified ID
IList listOfPosts = forumManager.GetForumThreads(firstForum, false);
// get first post of the list
Telerik.Forums.IPost thirdRootPost = forumManager.GetPost(((Telerik.Forums.IPost)listOfPosts[1]).ID);
Guid thirdRootPostId = thirdRootPost.ID;
// delete the post
forumManager.DeletePost(thirdRootPostId);
}
|
See Also