My answers to questions about generating static pages for aspx files

Source: Internet
Author: User

Http://community.csdn.net/Expert/topic/4402/4402646.xml
Question: _____ a piece of code for generating a static page. Thank you.
Author: vvf032 (effort)
Level 1:
Reputation: 100
Community:. NET technology ASP. NET
Number of questions: 100
Reply times: 25
Posting time: 14:14:15

I have a piece of code that converts a page into a static page. For example, if you put it in a button event in A. aspx
In A. aspx, set a. aspx ---> a.htm
But now, I want to put B. aspx ---> B .htm, role
I don't know how to modify this code and get B. aspx information. Thank you for your help.
Response. charset = ""
Me. enableviewstate = false
Dim TW as system. Io. stringwriter = new system. Io. stringwriter
Dim wt as htmltextwriter = new htmltextwriter (TW)
Dim path as string = "C: \ Inetpub \ wwwroot \ IEC \ a.htm"
Dim wter as system. Io. streamwriter = system. Io. file. createtext (PATH)
Me. rendercontrol (wt)
Wter. Write (TW. tostring)
Wter. Close ()
Wt. Close ()
Tw. Close ()
Response. End ()
Response. Redirect (PATH)
-------------------------------------------------------------------------
Use
Server. Execute ("B. aspx", TW );
Try.
---------------------
I have never used this method. Generally, the method for generating static pages is to first create an empty template HTML file, read aspx, name it, and write it to the new HTML. For details, refer to the following:
Http://blog.csdn.net/lvmenglong/archive/2005/08/13/453617.aspx
Http://blog.csdn.net/gonaly/archive/2005/03/05/312071.aspx
Http://blog.csdn.net/cncca/archive/2005/06/22/400669.aspx
Http://blog.csdn.net/aoyux/archive/2004/10/14/135705.aspx

I think there must be a solution to this problem.
Send your project (at least this page and its code) to my mailbox realzeus@gmail.com for convenience
I will be back tomorrow night to help you.

After reading the code, you can add the following statement under your A. aspx button2 to generate the static page of B. aspx:
Response. charset = "gb2312"
Me. enableviewstate = false
Dim TW as system. Io. stringwriter = new system. Io. stringwriter
Tw. encoding. getencoding ("gb2312 ")
Dim wt as htmltextwriter = new htmltextwriter (TW)
Server. Execute ("B. aspx", TW)
Dim path as string = server. mappath ("a.htm ")
Dim wter as system. Io. streamwriter
Wter = system. Io. file. createtext (PATH)
'Me. rendercontrol (wt)
Wter. Write (TW. tostring)
Wter. Close ()
Wt. Close ()
Tw. Close ()
Response. End ()
'Response. Flush ()

Reply to: zeusvenus (qingliu, please send a message for discussion) () Credit: 110 1:09:00 score: 93

I sent the entire code to your mailbox, and now I basically don't need VB. NET. The syntax is almost forgotten :)
The above code has passed the test in vs. net2003 and vs. net2005beta2.
The Garbled text is because your entire project code is UTF-8, So you open it in the browser and select "View"-"encoding"-"Unicode (UTF-8) in the browser menu). If you want to set the default value to gb2312, you can set the encoding method of Web. config and each Aspx. regx and the encoding method saved for each output to gb2312. This is not a problem.

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.