1

我有一个用于邮件功能的 html 页面。我在 stringbuilder 类型的对象中获取它,在代码后面并替换值。

.htm 文件中有一个特定的行,我想在特定情况下通过代码隐藏。我怎样才能找到那行并隐藏。

.htm 行:

<TR bgcolor="E96F00">
     <TD style="font-family: Arial; font-size: 14px; font-weight: Bold; color:White;">Course Content Link</TD>
</TR>
<TR>
     <TD style="font-family: Calibri; font-size: 14px;">@CourseContent@<BR>&nbsp;</TD>
</TR>

<TR>
     <TD style="font-family: Calibri; font-size: 14px; color:Red; font-weight:bold">Important: TD>
</TR>

我试图替换的代码后面的代码:

if (dt.Rows[0]["Type"].ToString() == "V")
{
     if (dt.Rows[0]["CourseContentPath"].ToString() != string.Empty)
     {
          x.Replace("@CourseContent@", "<A href='" + CourseContentLink + "' target=_blank onclick='window.open(this.href, this.target,'height=1000px,width=1000px'); 
          return false>Click here</A> to find the course content");
      }
}
if (dt.Rows[0]["Type"].ToString() == "A")
{

}
4

1 回答 1

0

如果你想隐藏一些东西,你可以尝试下面的简单逻辑

HTML

 <table>...
  <tr id="important">some TDs html</tr>
 </table>

尝试在后面的代码中 将此字符串转换为 XML 文档并检查逻辑并使用 id=important 删除 tr 节点

然后再次将 Xml Document 转换为 string 。

对于字符串到 XML 的转换检查http://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx

这会有帮助吗?

于 2012-10-19T08:03:52.187 回答