SoFunction
Updated on 2025-04-08

Example code protected override void Render(HtmlTextWriter writer)

protected override void Render(HtmlTextWriter writer)
{
//Compress the final output html before outputting
StringWriter html = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(html);
(tw);
string outhtml = ();
outhtml = (outhtml, "\\s+", " ");
outhtml = (outhtml, ">\\s+<", "><");
outhtml = ();
(outhtml);
}

protected override void Render(HtmlTextWriter writer)
{
//Save it as an html file before the final output. If the latest information is published, it can be opened once, and then it will generate html again.

//This is the default Render implementation, which is output directly to the writer
//(writer);
StringWriter html = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(html);
//Write the generated HTML into the tw we defined through the() method
(tw);
string path = ("");
StreamWriter sw = new StreamWriter(path, false, );
//Write to file
(());
();
//Write to the writer to output the page's HTML
//Note that you cannot call (writer) here, an error will occur
(());
}