using System; using System.Runtime.InteropServices; using System.Web.UI; using System.Web.UI.WebControls.WebParts; using System.Xml.Serialization; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.WebPartPages; namespace NewLightBox { [Guid("148b47a8-0e84-423d-bb3f-44e5f2e33dea")] public class NewLightBox : System.Web.UI.WebControls.WebParts.WebPart { protected override void Render(HtmlTextWriter writer) { SPSite mysite = new SPSite("http://" + System.Environment.MachineName); mysite = SPControl.GetContextSite(Context); SPWeb myweb = mysite.OpenWeb(); myweb = SPControl.GetContextWeb(Context); SPList mylist = myweb.Lists["Picture Library"]; SPQuery myquery=new SPQuery(); myquery.Query=""; string path = mysite.ServerRelativeUrl.ToString() + "Picture Library/"; SPListItemCollection mylstcol = mylist.GetItems(myquery); if (mylstcol.Count > 0) { foreach (SPListItem mylstitem in mylstcol) { writer.Write(""); writer.Write(""); writer.Write(" "); } } else { this.Page.Response.Write("No image found"); } // TODO: add custom rendering code here. // writer.Write("Output HTML"); } } }