Template page
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
</Head>
<Body>
<Div style = "width: pixel PX; Height: 54px" align = "center">
<Br/>
Title
</Div>
<Div style = "width: pixel PX; Height: 8px">
Browse <font color = "red">
<SCRIPT src = "http: // localhost/. Net/newsfiles/clickcount. aspx? Newsid = newsid "> </SCRIPT>
</Font> time
</Div>
<Div style = "width: pixel PX; Height: 100px">
Content
</Div>
<Div style = "width: 416px; Height: 9px">
Pager
</Div>
<Div style = "width: 416px; Height: 8px">
<Form ID = "form1" Action = ".../addcomment. aspx" style = "margin: 0px">
<Input id = "text1" type = "text"/>
<Br/>
<Textarea id = "commentcontent" Cols = "20" rows = "2"> </textarea>
<Br/>
<Input id = "newsid" type = "hidden" value = "newsid"/>
<Input id = "button1" type = "Submit" value = "button"/>
<A href = "http://www.dwww.cn/News/Display.aspx? Newsid = newsid "> View more comments </a>
</Form>
</Div>
</Body>
</Html>
Code Generation:
Using system; using system. collections. generic; using system. LINQ; using system. web; using system. web. ui; using system. web. UI. webcontrols; using system. io; public partial class Add: system. web. UI. page {protected void page_load (Object sender, eventargs e) {} protected void button#click (Object sender, eventargs E) {string content = "whether the method of sending the message is sent | the method of Fan DESA's fee"; string htmlstr = string. empty; string [] contentstr = content. split ('| '); string strtable = "<Table> <tr> <TD> upurl </TD> <TD> Number </TD> <TD> downurl </TD> </tr> </ table> "; // The upper and lower pages. Note that the upurl (Previous Page), number (page number), and downurl (next page) int pagenumber = contentstr. length; For (INT m = 0; m <pagenumber; m ++) {string numberstr = string. empty; string filepath = string. empty; For (INT I = 1; I <= pagenumber; I ++) {if (I = 1) {numberstr + = "[<a href = '" + datetime. now. tostring ("yyyymmddhhmmss") + ". html "+" '> "+ I +" </a>] ";} else {int P = I-1; numberstr + =" [<a href =' "+ datetime. now. tostring ("yyyymmddhhmmss") + "_" + P + ". html "+" '> "+ I +" </a>] ";}} if (M = 0) {filepath = server. mappath (". ") +" // "+ datetime. now. tostring ("yyyymmddhhmmss") + ". html ";} else {filepath = server. mappath (". ") +" // "+ datetime. now. tostring ("yyyymmddhhmmss") + "_" + M + ". html ";} using (streamreader sr = new streamreader (server. mappath ("newsfiles/template.html"), system. text. encoding. getencoding ("gb2312") {htmlstr = sr. readtoend ();} htmlstr = htmlstr. replace ("title", "generate static page pagination"); htmlstr = htmlstr. replace ("newsid", "11"); htmlstr = htmlstr. replace ("time", datetime. now. tostring ("yyyy/mm/DD"); htmlstr = htmlstr. replace ("content", contentstr [m]); htmlstr = htmlstr. replace ("pager", strtable. replace ("Number", numberstr); fileinfo file = new fileinfo (filepath); stream FS = file. openwrite (); Using (streamwriter Sw = new streamwriter (FS, system. text. encoding. getencoding ("gb2312") {SW. write (htmlstr );}}}}