ASP. NET Render Method

Source: Internet
Author: User

Previously, I used HttpModule to change the Cookie before Response. Today, ASP. NET Self-made ideas, converting the representation of the hard-to-use conversion of Chinese characters into Chinese characters, not ASP. NET Web control, that is, the Html control Ranat = server will be forcibly converted into Chinese characters for output.

If you write a line of the page content in Response, it is too tired and error-prone. So the best way is to perform another conversion after ASP. NET is generated, so ASP. NET won't be able to take you.

All ASP. NET Generation actions are completed in the Render method, so we will perform the operation on the Render method:

 
 
  1. Protected override void Render (HtmlTextWriter writer)
  2. {
  3. StringWriterSw=NewStringWriter ();
  4. HtmlTextWriterHtmlw=NewHtmlTextWriter (sw );
  5. // Extract the page generated content
  6. Base. Render (htmlw );
  7. Htmlw. Flush ();
  8. Htmlw. Close ();
  9. StringPageContent=Sw. ToString ();
  10. // Modify the content
  11. PageContent=KillTheBugAndShit(PageContent );
  12. Response. Write (pageContent );
  13. // Base. Render (writer );
  14. }

By using the Render method, you can also take out the content generated by the page to generate a static page.

  1. DataList and Repeater controls of ASP. NET
  2. Analysis of IIS ing in ASP. NET
  3. Overview ASP. NET status types
  4. Introduction to ASP. NET and Web servers
  5. EnableViewState attribute of ASP. NET

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.