我想从一个文件夹中读文件,若为图片则直接显示,若为其他文件,显示超连接,现在的问题是:
如何控制每幅图片的宽度和高度?如何设置两幅图片之间间距?如果有两个或多个超连接如何设置间距或换行显示?

解决方案 »

  1.   

    因为事先不知道有多少个附件,我是想在panel中每加一个控件都能换行。请问怎样实现?
      

  2.   

    //*****在panel面板中放一个table可以设置两个图片之间的间隔,在table放一个<img>对象设置图片的高度,设置多个超连接用foreach
     <asp:Panel ID="PanControl" runat="server">
                <table border="0" cellpadding="2" cellspacing="4">
                    <tr>
                        <td>
                            <img src="images/default.gif" border="0" align="absmiddle" width="100" height="100" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>//*****生成多个超连接代码
    public static void GetDirecotryFile(string DirecotrPath,out StringBuilder  strTemp)
        {
            strTemp = null;        DirectoryInfo mdirectoryinfo=new DirectoryInfo(DirecotrPath);
            FileInfo[] fileInfo = mdirectoryinfo.GetFiles();        int filecount = fileInfo.Length;        for (int i = 0; i < filecount; i++)
            {
                string FileExiten = fileInfo[i].FullName.Substring(fileInfo[i].FullName.LastIndexOf(".") + 1);            if (FileExiten.ToLower() != "jpg" && FileExiten.ToLower() != "gif")
                {
                    strTemp.Append("<a href=\"fileinfo.aspx?=filename=" + fileInfo[i].Name + "\" target=\"_blank\">" + fileInfo[i].Name + "</a>");
                }
            }    }
      

  3.   

    我的image是动态生成的,用代码实现的。现在我的问题是:
    如何的到image的宽度?如何换行?部分代码如下:
    if( strType == "gif" || strType == "jpg" || strType == "jpeg" || strType == "bmp")
    {
    System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
    img.ImageUrl = "inputNews"+ "\\"+ fileName.Substring(fileName.LastIndexOf("\\") +1);
    if(img.width.value > 480 )
    {
        img.Attributes.Add("width","480px");
    }
    this.picPanel.Controls.Add(img);
    }可是我if语句所获得的image.width.value = 0,这是为什么?