Static Page comment processing and List Processing

Source: Internet
Author: User
3. Update comments. The update process of comments is complicated because adding comments is an interactive process and static pages cannot complete this operation. The solution is to hand over the comments to another page (for example, remark. aspx. The specific process is: use form to remark the static page. aspx transmits the comment content, remark. aspx receives comments, adds comments, updates static pages of an article, and redirects to static pages. In this way, the comment is added.

 

Code in form:

Comment:

 

Code for related operations in remark. aspx:

Protected override void onload (eventargs E)

{

Base. onload (E );

 

Int narticleid = int. minvalue; // Article ID

Int nclassid = int. minvalue; // category ID

 

Try

{

// Obtain input parameters

Narticleid = int. parse (this. Request. querystring ["ArticleID"]);

Nclassid = int. parse (this. Request. querystring ["classid"]);

}

Catch

{

}

 

// Check validity

If (narticleid <1 | nclassid <1)

{

This. response. Redirect ("/error.html", true );

}

String sremarkbody = This. Request. Params ["remarkbody"];

 

// Format:/show. aspx? Id = 456 & cid = 123

String sfrom = string. Concat ("/show. aspx? Id = ", narticleid," & cid = nclassid );

 

// Format:/news/123/456 .html

String sto = string. Concat ("/news/", nclassid, "/", narticleid, ". html ");

 

If (sremarkbody! = NULL & sremarkbody. length> 0)

{

// Add comments

Insertremark (narticleid );

 

// Generate a static page

Makestatic (sfrom, this. mappath (STO ));

}

 

// Turn to the static page

This. response. Redirect (STO, true );

}

 

The static pages processed in this way are exactly the same as other static pages during normal browsing, but they only treat the updated comment program during comments. The overall reception speed is still very fast.

The second case is the news classification list page. This type of page changes greatly when managing news, and it is inconvenient to use background management. This requires some programs to help administrators manage these pages. The program idea has been mentioned earlier, and the program code that can be applied is provided here.

 

Protected override void onload (eventargs E)

{

Base. onload (E );

 

Int nclassid = int. minvalue; // category ID

Int npage = int. minvalue; // page number

Try

{

// Obtain input parameters

Nclassid = int. parse (this. Request. querystring ("classid "));

Npage = int. parse (this. Request. querystring ("page ");

}

Catch

{

}

 

// Check validity

If (nclassid <1)

{

This. response. Redirect ("/error.html", true );

}

Else if (npage <1)

{

Npage = 1;

}

 

// Format:/list. aspx? Cid = 123 & page = 456

String sfrom = string. Concat ("/list. aspx? Cid = ", nclassid," & page = ", npage );

 

// Format:/news/123/default456.html

String sto = string. Concat ("/news/", nclassid, "/Default", (npage = 1 )? (""): (Npage), ". html ");

String Spath = This. mappath (STO );

 

If (! File. exists (Spath ))

{

// Create a static page when the file does not exist

Makestatic (sfrom, STO );

}

Else

{

Timespan Ts = datetime. Now-file. getlastwritetime (Spath );

 

If (TS. totaldays> 1)

{

// The file already exists, but it takes too long to be updated

Makestatic (sfrom, STO );

}

}

 

// Turn to the static page

This. response. Redirect (STO, 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.