Programmatically Checking if a SharePoint Element is Published
Here’s a quick tip for you: How to check if the latest version of an element in a SharePoint list is published.
Once you’ve got hold of an SPListItem, you can check the Versions property (an array containing all the versions of the element).
In this block of code IsPublished becomes True if the latest version is published:
![bool IsPublished = TheItem.Versions[0].Level == SPFileLevel.Published ? true : false;](http://sharepointsharpener.files.wordpress.com/2009/03/image5.png?w=701&h=51)
That’s it.
Thanks. save me some hours
tzriad
June 22, 2009 at 9:25 am
if it is a file, you can also use this:
bool isPublished = (TheItem.File.Level == SPFileLevel.Published);
Ah Lun
July 30, 2009 at 11:01 am
Appreciated,helped me alot.
Basem
October 7, 2009 at 1:06 pm