I've built this app that displays employee photos stored in several sharepoint folders. It also displays the employee name extracted from the file name and a previous and next button to move through the photos.
The markup is surrounded by an update panel to prevent the entire page from reloading when you click to view the next photo.
The app is working fine in firefox, but the images do not display in IE8. Can anyone tell what is causing this?
public List<string> photoFileList = new List<string>();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["index"] = 0;
Session["CountOfPictures"] = 0;
List<string> PhotoFolders = new List<string>();
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\Dept1");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept2");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept3");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept4");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept5”);
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept6");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept7");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept8");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept9");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept10");
PhotoFolders.Add("\\\\intranet.org\\Photo Album\\Employees\\ Dept11");
Session["AllPhotoFolders"] = PhotoFolders;
List<string> AllPhotoFolders = (List<string>)Session["AllPhotoFolders"];
foreach (string folder in AllPhotoFolders)
{
DirSearch(folder);
}
Session["AllPhotoFiles"] = photoFileList;
Image1.ImageUrl = photoFileList[0].Replace("\\", "//");
var list = (List<string>)Session["AllPhotoFiles"];
lblName.Text = System.IO.Path.GetFileName(list[0]).Substring(0, System.IO.Path.GetFileName(list[0]).Length - 4).Replace("_", " ");
Session["CountOfPictures"] = photoFileList.Count;
}
}
void DirSearch(string sDir)
{
foreach (string f in Directory.GetFiles(sDir, "*.JPG"))
{
//BulletedList1.Items.Add(f);
photoFileList.Add(f);
}
foreach (string d in Directory.GetDirectories(sDir))
{
if (!d.EndsWith("_t") && !d.EndsWith("_w"))
{ DirSearch(d);}
}
}
protected void btnNext_Click(object sender, EventArgs e)
{
int NextIndex = (int)Session["index"];
int PictureCount = (int)Session["CountOfPictures"];
NextIndex += 1;
if (NextIndex == PictureCount)
{
NextIndex = 0;
}
Session["index"] = NextIndex;
var list = (List<string>)Session["AllPhotoFiles"];
Image1.ImageUrl = list[NextIndex].Replace("\\", "//");
lblName.Text = System.IO.Path.GetFileName(list[NextIndex]).Substring(0,System.IO.Path.GetFileName(list[NextIndex]).Length - 4).Replace("_"," ");
lblName.Visible = true;
}
protected void btnPrevious_Click(object sender, EventArgs e)
{
int NextIndex = (int)Session["index"];
int PictureCount = (int)Session["CountOfPictures"];
NextIndex -= 1;
if (NextIndex == -1)
{
NextIndex = PictureCount - 1;
}
Session["index"] = NextIndex;
var list = (List<string>)Session["AllPhotoFiles"];
Image1.ImageUrl = list[NextIndex].Replace("\\", "//");
lblName.Text = System.IO.Path.GetFileName(list[NextIndex]).Substring(0, System.IO.Path.GetFileName(list[NextIndex]).Length - 4).Replace("_", " ");
lblName.Visible = true;
}
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br /><br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table>
<tr>
<td><asp:Image ID="Image1" runat="server" Height="400px" Width="400px" /></td>
<td> </td>
<td><asp:Label ID="lblName" runat="server" Text="Label" Font-Size="X-Large"></asp:Label></td>
</tr>
<tr > <td>
<div style="text-align:center"> <asp:Button style="text-align:center" ID="btnPrevious" runat="server" Text="Previous"
onclick="btnPrevious_Click" Width="125px" />
<asp:Button style="text-align:center" ID="btnNext" runat="server" Text="Next" onclick="btnNext_Click"
Width="125px" /></div></td></tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>