J'ai construit cette application qui affiche les photos des employés stockées dans plusieurs dossiers de partage. Il affiche également le nom de l'employé extrait du nom de fichier et un bouton précédent et suivant pour parcourir les photos.L'application Web fonctionne dans Firefox mais pas IE8
Le balisage est entouré d'un panneau de mise à jour pour empêcher le rechargement de la page entière lorsque vous cliquez pour afficher la photo suivante.
L'application fonctionne très bien dans Firefox, mais les images ne s'affichent pas dans IE8. Quelqu'un peut-il dire ce qui cause cela?
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>
Est-ce que les images apparaissent comme endommagées dans IE8? –
Que se passe-t-il lorsque vous affichez l'URL complète de l'image dans la barre d'adresse de Firefox? –
Dave, en ie8 vous pouvez voir le contour de l'image carrée où l'image devrait s'afficher et une petite boîte grise avec un rex 'X' dans le coin supérieur gauche –