How to insert script or other text information in asp.net results

Source: Internet
Author: User

Problem:

Delivery of a customer's website some time ago. The customer proposed to speed up the webpage when loading FLASH, and requested some improvement.

I wrote the Flash content as a control and added some attributes that Flash needs to use to generate scripts and insert them to the page. It turns out to be directly executed in the page insertion position.

Rewrite the original control as required by the customer. Only one HTML Tag is generated for the original script execution location, and the corresponding script is added to the footer for insertion.

This requires operations on the results generated on the original aspx page.

Answer:

Create your own Page class, inherit from the original System. Web. UI. Page, and generate related writing methods. The specific code is as follows:

Copy to ClipboardReference: [www.bkjia.com] Public Class MyPageClass MyPage
Inherits System. Web. UI. Page

Dim sw As New System. IO. StringWriter
Dim _ writer As System. IO. TextWriter

Protected Overrides Function CreateHtmlTextWriter () Function CreateHtmlTextWriter (ByVal tw As System. IO. TextWriter) As System. Web. UI. HtmlTextWriter
_ Writer = MyBase. CreateHtmlTextWriter (tw)
Return MyBase. CreateHtmlTextWriter (sw)
End Function

Protected Overrides Sub Render () Sub Render (ByVal writer As System. Web. UI. HtmlTextWriter)
MyBase. Render (writer)

_ Writer. Write (Replace (sw. ToString, "</body>", "Custom content </body>", 1,-1, CompareMethod. Text ))
End Sub

End Class

 

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.