none
how to enable Version programatically to a document library?

    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

Answers

  • 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;
    
                  list.Update();
                }
              }
    
    

     

    Wednesday, January 12, 2011 2:08 AM

All replies