在div中显示图片

来源:互联网 发布:页游制作软件 编辑:程序博客网 时间:2022/05/28 05:23

后台:

       string tmp = string.Empty;
                    string picpath = "../UploadFiles/" + datatable.Rows[0]["PicPath"].ToString();
                    tmp += displayImageFlash(picpath);

     显示在:

     string t = string.Empty;
                    t = t + string.Format("{0}<br/>{1}", tmp, datatable.Rows[0]["Body"].ToString());
                    this.body.InnerHtml = t;

body为页面div的Id;

方法:

    /// <summary>
    /// 利用url路径判别上传的类别,如果是flash、图片的话显示在内容里面
    /// </summary>
    /// <param name="Url"></param>
    /// <returns></returns>
    private string displayImageFlash(string Url)
    {
        string tmp = string.Empty;
        string ExtName = Path.GetExtension(Url);
        string DocumentExt = ".doc,.docx,.xls,.xlsx,.txt,.rar,.zip";
        Url = Url.Replace("~", ".");
        if (ExtName.ToLower() == ".swf")
            tmp += InerHtml.InsertFlashHtml(Url, 600, 0);
        else
        {
            if (DocumentExt.Contains(ExtName.ToLower()))
                this.body.InnerHtml += InerHtml.InsertArticleAccess(Url);
            else
                tmp += InerHtml.InsertImageHtml(Url, 600, 0);
        }
        return tmp;


    }

原创粉丝点击