. Net generates the detail page and list as static page 1

Source: Internet
Author: User
. Net generates the detail page and list as static pages 12010-01-27

Using system;
Using system. Collections. Generic;
Using system. text;
Using system. IO; // namespace of streamreader
Using system. Data;
Using *** _ logic; // The internal project space to hide it

Namespace DB
{
Public class createdb
{
/// <Summary>
//// // Generate a detailed page
/// </Summary>
/// <Param name = "strmfile"> template file name </param>
/// <Param name = "Strid"> News id </param>
/// <Param name = "strtilte"> News Title </param>
/// <Param name = "strcontents"> news content </param>
/// <Returns> </returns>
Public bool makehtmlfile (string strmfile, string Strid, string strtilte, string strcontents)
{
// Create HTML Encoding
Encoding ED = encoding. getencoding ("gb2312 ");
// Obtain the address for storing the template-relative path
String strpath = system. Web. httpcontext. Current. server. mappath ("../html /");
// Read the Template File
String strtemp = system. Web. httpcontext. Current. server. mappath ("../module/" + strmfile );
// Read the object
Streamreader sr = NULL;
// Write object
Streamwriter Sw = NULL;
String STR = "";

// Read the Template File
Sr = new streamreader (strtemp, Ed );

// Read the last row and assign it to Str
STR = Sr. readtoend ();

// Automatically generate the HTML file name
// String htmlfilename = strpath + datetime. Now. tostring ("yyyymmddhhmmss") + ". html ";
String htmlfilename = strpath + Strid + ". html ";
// Replace the value in the template with the value obtained from the text box.
STR = Str. Replace ("newstitle", strtilte );
STR = Str. Replace ("newsbody", strcontents );
// Start writing the created HTML file
Sw = new streamwriter (htmlfilename, false, Ed );
Sw. Write (STR );
Sw. Flush ();
Sw. Close ();
Return true;
}

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.