Asp.net instance Code protected override void render (htmltextwriter writer)

Source: Internet
Author: User

Protected override void render (htmltextwriter writer)
{
// Compress the HTML to be output before outputting it
Stringwriter html = new stringwriter ();
Htmltextwriter Tw = new htmltextwriter (HTML );
Base. Render (TW );
String outhtml = html. tostring ();
Outhtml = RegEx. Replace (outhtml, "\ s + ","");
Outhtml = RegEx. Replace (outhtml, ">\\ S + <", "> <");
Outhtml = outhtml. Trim ();
Writer. Write (outhtml );
}

Protected override void render (htmltextwriter writer)
{
// Before the final output, the file is saved as an HTML file. If the latest information is published, you can open default. aspx once and then generate another HTML file.

// This is the default render implementation and is directly output to writer.
// base. render (writer);
stringwriter html = new stringwriter ();
htmltextwriter Tw = new htmltextwriter (HTML);
// use base. the render () method writes the generated HTML to our defined TW
base. render (TW);
string Path = server. mappath ("index.html");
streamwriter Sw = new streamwriter (path, false, system. text. encoding. default);
// write to file
SW. write (HTML. tostring ();
SW. close ();
// write to writer to output HTML of the page
// note that base cannot be called here. render (writer), error
writer. write (HTML. tostring ();
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.