how to enable Version programatically to a document library? RRS feed

  • Question

  • Hi,


    Will anybody suggest me how to enable Version programatically to a document library for which am creating the it in a custom way and am binding it with to the Quuick Launch.

    But i want Version History for the records present in the document library with out doing the above standard procedure actions as mentioned above.

    Pls advice !!!


    Thanks in Advance !!! Cheers !!! Praveen Mandalapu
    • Split by Mike Walsh FIN Tuesday, January 11, 2011 3:21 PM New question in existing 3 month old thread
    Tuesday, January 11, 2011 2:54 PM


  • In addition to Giuseppe's comment, there are a few other properties you can use to tweak the versioning settings. Code expample below

              using (SPSite site = new SPSite("http://siteurl"))
                using (SPWeb web = site.OpenWeb())
                  SPList list = web.Lists["listname"];
                  //switch on versioning
                  list.EnableVersioning = true;
                  //enable minor versions for documents
                  list.EnableMinorVersions = true;
                  //set maximum limits for major/minor versions
                  list.MajorVersionLimit = 5;
                  list.MajorWithMinorVersionsLimit = 5;


    • Proposed as answer by Hemendra Agrawal Wednesday, January 12, 2011 8:50 AM
    • Marked as answer by Porter Wang Thursday, January 13, 2011 2:58 AM
    Wednesday, January 12, 2011 2:08 AM

All replies