How to checkout/checkin document(s) from ASP.Net code in Kentico CMS 8?

Binod Paikaray asked on April 27, 2016 10:24


I need to bulk update some content of the Form tab for which I am going to write some code in ASP.Net to update in Kentico DB. But just to maintain the version history of the documents (which are being updated by my code) I want to checkout the documents first and then update it's content and then check it in back. All these actions I need to perform by my newly created API in which I have included all Kentico libraries. I don't want to use the existing Kentico API for this to do it one by one.

Any kind of quick help will be highly appreciated.

Thanks Binod Paikaray

Recent Answers

Brenden Kehren answered on April 27, 2016 14:18

This documentation is for v9 but I believe the code is the same for v8.

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on April 28, 2016 15:43

Brenden has provided you with documentation. However if you are looking for specific code to solve your problem you can do something like this.

// Gets the latest edited version of child pages stored under the '/Articles/' path
// The pages are retrieved from the Dancing Goat site and in the "en-us" culture
// Replace Path and SiteName to match your site
var pages = DocumentHelper.GetDocuments()
    .Path("/Articles/", PathTypeEnum.Children)
    .WhereLike("DocumentName", "Coffee%")

// Updates the "DocumentName" and "ArticleTitle" fields of each retrieved page
// You should perform your logic here. In this case It is updating the DocumentName and ArticleTitle
foreach (TreeNode page in pages)
    // Checks if the page isn't already checked-out
    if (!page.IsCheckedOut)
        // Checks out the page

        page.DocumentName = "Updated article name";
        page.SetValue("ArticleTitle", "Updated article title");

        // Updates the page in the database

        // Checks in the page

This should help you achieve most of what you are looking for

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.