如何删除字符串生成器表中的神秘边框?

时间:2017-01-04 16:47:54

标签: html css asp.net .net stringbuilder

我有一些生成PDF的代码。出于某种原因,在这一行的图像后面出现了一个黑色边界单元格:

sb.AppendLine("<tr><td>" + "~/images/Products/" + imageName + "</td><td>~/images/spacer.gif</td></tr>");

我已尝试在桌面上将边框设置为0,但我收到错误“)预期”,或者html刚刚中断。

如何确保此单元格周围没有显示边框?

以下是涉及的两个部分:

//add images
        str = new StringBuilder();
        str.Append("<table>");

        if (HasRelatedImages(ContentId, ref str))
        {
            obj = new List<FieldIdentifier>();
            obj.Add(new FieldIdentifier() { LabelName = "Images", Value = "" });
            index = index + 1;
            rows.Add(index, obj);

            obj = new List<FieldIdentifier>();
            obj.Add(new FieldIdentifier() { LabelName = "NewTable_Data", Value = str.Append("</table>").ToString() });
            index = index + 1;
            rows.Add(index, obj);
        }
        //end images

private Boolean HasRelatedImages(long productId, ref StringBuilder sb)
{
    var imagemetadata = new List<ImageMetadata>();
    int i = 0;

    try
    {
        Database db = DatabaseFactory.CreateDatabase("Site.DbConnection");
        DbCommand dbCommand = db.GetStoredProcCommand("[spSelectImages]");
        db.AddInParameter(dbCommand, "@ContentID", DbType.Int64, productId);
        IDataReader dr = db.ExecuteReader(dbCommand);

        while (dr.Read())
        {
            string imageName = GetNullableDBStringValue(dr["ImageName"]);
            string altText = GetNullableDBStringValue(dr["ALTText"]);
            altText = HttpUtility.HtmlEncode(altText);

            if (!string.IsNullOrEmpty(imageName) && System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/images/Products/" + imageName)))
            {
                i++;

                sb.AppendLine("<tr><td>" + i.ToString() + "</td><td>" + (string.IsNullOrEmpty(altText) ? " " : altText) + "</td></tr>");
                sb.AppendLine("<tr><td>" + "~/images/Products/" + imageName + "</td><td>~/images/spacer.gif</td></tr>");
            }

        }
        dr.Close();
    }
    catch
    {
    }


    if (i > 0) return true;

    return false;
}

1 个答案:

答案 0 :(得分:0)

还有其他代码涉及添加边框。这件作品不需要改变。