我構建了一個應該用於生成HTML表的字符串。我不能讓文本顯示爲HTML,但它只是以純文本形式寫入。如何將StringBuilder的內容顯示爲HTML?
這裏是我建立字符串的地方: StringBuilder HTMLTable = new StringBuilder();
HTMLTable.AppendLine("<html>");
HTMLTable.AppendLine("<head>");
HTMLTable.AppendLine("<style type=\"text/css\">");
HTMLTable.AppendLine(" .thd {background: rgb(220,220,220); font: bold 10pt Arial; text-align: center;}");
HTMLTable.AppendLine(" .team {color: white; background: rgb(100,100,100); font: bold 10pt Arial; border-right: solid 2px black;}");
HTMLTable.AppendLine(" .winner {color: white; background: rgb(60,60,60); font: bold 10pt Arial;}");
HTMLTable.AppendLine(" .vs {font: bold 7pt Arial; border-right: solid 2px black;}");
HTMLTable.AppendLine(" td, th {padding: 3px 15px; border-right: dotted 2px rgb(200,200,200); text-align: right;}");
HTMLTable.AppendLine(" h1 {font: bold 14pt Arial; margin-top: 24pt;}");
HTMLTable.AppendLine("</style>");
HTMLTable.AppendLine("</head>");
HTMLTable.AppendLine("</html>");
HTMLTable.AppendLine("<body>");
HTMLTable.AppendLine("<h1>Tournament Results</h1>");
HTMLTable.AppendLine("<table border=\"0\" cellspacing=\"0\">");
for (int row = 0; row <= max_rows; row++)
{
cumulative_matches = 0;
HTMLTable.AppendLine(" <tr>");
//等等,等等
然後我這個字符串添加到我的.cshtml文件相關聯的viewbag。我試過這樣的東西:
<text>@ViewBag.bracketHTML</text>
但這並不起作用。有任何想法嗎?
我注意到你之前'
有'' '。它不應該在你的標記最後(在'