We help IT Professionals succeed at work.

How to write HTML out to aspx page from C#

jayv21
jayv21 asked
on
I'm trying to write some HTML out to the screen stored in a variable, I don't want to write the literal value I want to generate the page based on the HTML.  PageData is the variable that contains the HTML.  How would I write this out to the ASPX page and generate the HTML?  Thanks for any help.




public partial class PrintPreview : CommonPage
{
   public PrintPreview()
   {
        string Debug = "";
        string PageData = "";
        string htmlCode = Request.QueryString.Get("HTML");
     
        try
        {

            string[] results = BAL.processReprints(htmlCode);
            PageData = results[0].ToString();
           
        }
        catch (Exception ex)
        {
            Logging.LogEntry(ex.Message);
           
        }
    }
}

Comment
Watch Question

Top Expert 2006

Commented:
You can write raw HTML out to your ASPX page by using Response.Write.
Commented:
If you are on the webpage you could use:
Page.Response.Write("my text");
or
Page.Controls.Add(new System.Web.UI.LiteralControl("my text"));

If you do not have access to page object (programming within a class), you could use:

System.Web.HttpContext.Current.Response.Write ("my text");

Author

Commented:
Thanks