Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Web应用程序在Firefox中工作,但在IE8中不工作_C#_Asp.net_Asp.net Ajax - Fatal编程技术网

C# Web应用程序在Firefox中工作,但在IE8中不工作

C# Web应用程序在Firefox中工作,但在IE8中不工作,c#,asp.net,asp.net-ajax,C#,Asp.net,Asp.net Ajax,我构建了这个应用程序,可以显示存储在多个sharepoint文件夹中的员工照片。它还显示从文件名中提取的员工姓名,以及在照片中移动的“上一步”和“下一步”按钮 标记由更新面板包围,以防止在单击查看下一张照片时重新加载整个页面 该应用程序在firefox中运行良好,但图像不会显示在IE8中。有人能说出是什么原因造成的吗 public List<string> photoFileList = new List<string>(); protected void Pa

我构建了这个应用程序,可以显示存储在多个sharepoint文件夹中的员工照片。它还显示从文件名中提取的员工姓名,以及在照片中移动的“上一步”和“下一步”按钮

标记由更新面板包围,以防止在单击查看下一张照片时重新加载整个页面

该应用程序在firefox中运行良好,但图像不会显示在IE8中。有人能说出是什么原因造成的吗

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>&nbsp;</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>
public List photoFileList=new List();
受保护的无效页面加载(对象发送方、事件参数e)
{
如果(!IsPostBack)
{
会话[“索引”]=0;
会话[“图片计数”]=0;
List PhotoFolders=新列表();
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”);
会话[“AllPhotoFolders”]=PhotoFolders;
List AllPhotoFolders=(List)会话[“AllPhotoFolders”];
foreach(所有PhotoFolders中的字符串文件夹)
{
目录搜索(文件夹);
}
会话[“所有照片文件”]=照片文件列表;
Image1.ImageUrl=photoFileList[0]。替换(“\\”,“/”;
var list=(list)会话[“AllPhotoFiles”];
lblName.Text=System.IO.Path.GetFileName(列表[0])。子字符串(0,System.IO.Path.GetFileName(列表[0])。长度为-4。替换(“",”);
Session[“CountOfPictures”]=photoFileList.Count;
}
}
void DirSearch(字符串sDir)
{
foreach(Directory.GetFiles(sDir,*.JPG)中的字符串f)
{
//项目清单1.项目。添加(f);
照片文件列表。添加(f);
}
foreach(Directory.GetDirectories(sDir)中的字符串d)
{
如果(!d.EndsWith(“\u t”)和(&!d.EndsWith(\u w”))
{DirSearch(d);}
}
}
受保护的void btnNext_单击(对象发送方,事件参数e)
{
int NextIndex=(int)会话[“索引”];
int PictureCount=(int)会话[“CountOfPictures”];
NextIndex+=1;
如果(NextIndex==PictureCount)
{
NextIndex=0;
}
会话[“索引”]=下一个索引;
var list=(list)会话[“AllPhotoFiles”];
Image1.ImageUrl=列表[NextIndex]。替换(“\\”,“/”;
lblName.Text=System.IO.Path.GetFileName(list[NextIndex]).Substring(0,System.IO.Path.GetFileName(list[NextIndex]).Length-4.替换(“u”,”);
lblName.Visible=true;
}
受保护的无效BTN上一次单击(对象发送者,事件参数e)
{
int NextIndex=(int)会话[“索引”];
int PictureCount=(int)会话[“CountOfPictures”];
NextIndex-=1;
如果(NextIndex==-1)
{
NextIndex=PictureCount-1;
}
会话[“索引”]=下一个索引;
var list=(list)会话[“AllPhotoFiles”];
Image1.ImageUrl=列表[NextIndex]。替换(“\\”,“/”;
lblName.Text=System.IO.Path.GetFileName(list[NextIndex]).Substring(0,System.IO.Path.GetFileName(list[NextIndex]).Length-4.替换(“u”,”);
lblName.Visible=true;
}



我想我重现了这个问题

您没有将http:添加到url,而是将斜杠加倍。代码将生成如下输出:

<img src="////intranet.org//image//path//some_image.jpg">

这实际上似乎在Firefox和Chrome中有效,但在IE中无效。问题不在于文件夹/文件名之间的双斜杠,而是前面的四个


删除双斜杠(如替换文件路径中的每个反斜杠),如我在注释中建议的那样,应该先解决它。“链接到url,使其格式正确。

IE8中的图像是否显示为已损坏?当您在Firefox的地址栏中显示图片的完整url时会发生什么?Dave,在IE8中,您可以看到图片应显示的方形图像轮廓和左上角带有rex‘X’的灰色小框,当我在firefox中粘贴照片url时,它会显示照片(在ie8中也是如此),这看起来与您的错误有关。当我尝试将路径更改为“PhotoFolders.Add”(“http:\\intranet….”)时,我遇到了这个错误“URI格式不受支持”。当您查看HTML输出的源代码时,您的代码为img生成了什么内容?关于路径,您是对的。我将此行Replace(“\\”,“/”)更改为Replace(“\\”,“/”)现在它可以在ie和firefox中使用。谢谢you@Joshua由于jamietre的回答解决了你的问题,你应该奖励他的问题。如果你有这样做的问题,请参阅“我如何奖励奖励”: