title: build and display an html page in a table cell aspx c#
body: <p>I have to create some reports for my project. My solution for desktop applications was to use a form with a "web browser" component, build the report in html, and use the html string as the display text. This works very well and allows me to create custom reports without any reporting tools (I'm using the express versions of VS. No reporting tools included). However, I have no idea how to do this in an aspx page. I can build the report, just need to know how to get it in the target cell and how to make sure the report is displayed properly and not as the raw string that holds it. </p>
  
  <p>code below:</p>
  
  <pre><code>&lt;table style="width: 100%; height: 690px;"&gt;
     &lt;tr&gt;
        &lt;td class="auto-style2"&gt;Select Report Type&lt;/td&gt;
        &lt;td class="auto-style3"&gt;
           &lt;asp:Button ID="btnTodayReport" runat="server" OnClick="btnTodayReport_Click" Text="Today's Orders" /&gt;
        &lt;/td&gt;
        &lt;td class="auto-style4"&gt;
           &lt;asp:Button ID="btWeeklyReport" runat="server" Text="Weekly Report" OnClick="btnRunReport_Click" /&gt;
        &lt;/td&gt;
        &lt;td class="auto-style5"&gt;
           &amp;nbsp;
        &lt;/td&gt;
        &lt;td class="auto-style1"&gt;
           &amp;nbsp;&amp;nbsp;
        &lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
        &lt;td colspan="5" style="border-style: solid"&gt;**This is where the report should display**&lt;/td&gt;
     &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>As requested, below is the code to build the html string. It's from old code but I'll be using the same approach for this project, or at least would like to use this. wb is the WebBrowser component for a WinForms application.</p>
  
  <pre><code>private void btnGetReport_Click(object sender, EventArgs e)
      {
          // get the data for the report
          wb.DocumentText = RepBuild.BuildAverageReport(dtStart.Value, dtEnd.Value);
  
      }    
  
  public static string BuildReview(review rev)
      {
          int questID = 0;
          string Body = "";
  
          Body = "&lt;HTML&gt;&lt;HEAD&gt;&lt;META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=windows-1252\"&gt;" +
              "&lt;TITLE&gt;Ticket Review for " + rev.RevEmpName + "&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt;";
  
          Body += "&lt;TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 &gt;&lt;TR HEIGHT=40 &gt;" +
              "&lt;TD ALIGN=LEFT BGCOLOR=#FFFFFF &gt;&lt;FONT style=FONT-SIZE:18pt FACE=\"Segoe UI\" COLOR=#204d89&gt;Ticket Review for " + rev.RevEmpName + "&lt;/FONT&gt;&lt;/TD&gt;" +
              "&lt;/TR&gt;&lt;/TABLE&gt;&lt;TABLE HEIGHT=150&gt;&lt;/TABLE&gt;";
  
          // show the questions in order
          Body += "&lt;table border='1' width = '800px' align = 'center'&gt; &lt;tr&gt;" +
              "&lt;td rowspan = '3' width = '80px'&gt;&lt;b&gt;Number &lt;/b&gt;&lt;/td&gt;&lt;td rowspan = '3' width = '80px'&gt;&lt;b&gt;Score &lt;/b&gt;&lt;/td&gt;" +
              "&lt;td width = '600px'&gt;&lt;b&gt;Question &lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Comments&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/Table&gt;";
  
          while (questID &lt;= rev.RevQuestions.Count - 1)
          {
              if ((questID % 2) == 0)//the number is even
              {
                  Body += "&lt;table border='1' width = '800px' align = 'center'&gt;&lt;tr&gt;" +
                  "&lt;td rowspan = '3' width = '80px'&gt;" + rev.RevQuestions[questID].QuestID.ToString() + " &lt;/td&gt; &lt;td rowspan = '3' width = '80px'&gt; " +
                  rev.RevQuestions[questID].QuestScore + " &lt;/td&gt; " +
                  " &lt;td width = '600px'&gt; " + rev.RevQuestions[questID].QuestText + " &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt; " +
                  rev.RevQuestions[questID].QuestComment + " &lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; ";
  
              }
              else
              {
                  Body += "&lt;table border='1' width = '800px' align = 'center' bgcolor='#cccccc'&gt;&lt;tr&gt;" +
                  "&lt;td rowspan = '3' width = '80px'&gt;" + rev.RevQuestions[questID].QuestID.ToString() + " &lt;/td&gt; &lt;td rowspan = '3' width = '80px'&gt; " +
                  rev.RevQuestions[questID].QuestScore + " &lt;/td&gt; " +
                  " &lt;td width = '600px'&gt; " + rev.RevQuestions[questID].QuestText + " &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt; " +
                  rev.RevQuestions[questID].QuestComment + " &lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; ";
              }
  
              questID++;
          }
  
          Body += "&lt;BR&gt;&lt;BR&gt;";
  
          Body += "&lt;Table width = '400px' align = 'left'&gt;";
  
          Body += "&lt;TR&gt;";
          Body += "&lt;TD&gt;&lt;b&gt;Reviewed By&lt;/b&gt;&lt;/TD&gt;";
          Body += "&lt;TD&gt; " + rev.RevLeadName + "&lt;/TD&gt;";
          Body += "&lt;/TR&gt;";
  
          Body += "&lt;TR&gt;";
          Body += "&lt;TD&gt;&lt;b&gt;Review Date&lt;/b&gt;&lt;/TD&gt;";
          Body += "&lt;TD&gt; " + rev.RevDate.ToShortDateString() + "&lt;/TD&gt;";
          Body += "&lt;/TR&gt;";
  
          Body += "&lt;TR&gt;";
          Body += "&lt;TD&gt;&lt;b&gt;Overall Score&lt;/b&gt;&lt;/TD&gt;";
          Body += "&lt;TD&gt; " + rev.RevScore + " out of 100&lt;/TD&gt;";
          Body += "&lt;/TR&gt;";
  
          Body += "&lt;TR&gt;";
          Body += "&lt;TD&gt;&lt;b&gt;Ticket Date&lt;/b&gt;&lt;/TD&gt;";
          Body += "&lt;TD&gt; " + rev.RevTickDate + "&lt;/TD&gt;";
          Body += "&lt;/TR&gt;";
  
          Body += "&lt;TR&gt;";
          Body += "&lt;TD&gt;&lt;b&gt;Ticket Number&lt;/b&gt;&lt;/TD&gt;";
          Body += "&lt;TD&gt; " + rev.RevTickNum + "&lt;/TD&gt;";
          Body += "&lt;/TR&gt;";
  
          Body += "&lt;/TABLE&gt;";
  
          Body += "&lt;/HTML&gt;";
  
          return Body;
  
      }
  </code></pre>