Static Page statichtml.html
CopyCode The Code is as follows: <! 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> several methods for collecting dynamic page access volume </title>
</Head>
<Body>
This is displayed in the layer
<Div id = "PV"> </div>
<SCRIPT src = "addnumber. aspx"> </SCRIPT>
</Body>
</Html>
add page addnumber. aspx
<% @ page Language = "C #" autoeventwireup = "true" codefile = "addnumber. aspx. CS "inherits =" addnumber "%>
addnumber. aspx. CS
Code copy Code the code is as follows: public partial class addnumber: system. web. UI. page
{< br> Private Static int COUNT = 1;
protected void page_load (Object sender, eventargs e)
{< br> count ++;
response. write ("Var Pv = document. getelementbyid ('pv'); PV. innertext = "+ Count +"; ");
}< BR >}
Method 2:
Static Page statichtml.htmlCopy codeThe Code is as follows: <! 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> several methods for collecting dynamic page access volume </title>
</Head>
<Body>
This is to use images for display.
</Body>
</Html>
Accumulate page imageaddnumber. aspxCopy codeThe Code is as follows: <% @ page Language = "C #" autoeventwireup = "true" codefile = "imageaddnumber. aspx. cs" inherits = "imageaddnumber" %>
Imageaddnumber. aspx. CS
Code Copy code The Code is as follows: public partial class imageaddnumber: system. Web. UI. Page
{
Private Static int COUNT = 1;
Protected void page_load (Object sender, eventargs E)
{
Count ++;
String Pv = count. tostring ();
System. Drawing. bitmap image = new system. Drawing. Bitmap (INT) math. Ceiling (Pv. length * 12.5), 22 );
Graphics G = graphics. fromimage (image );
// Background color
G. Clear (color. White );
Font font = new system. Drawing. Font ("Arial", 12, (system. Drawing. fontstyle. Bold | system. Drawing. fontstyle. italic ));
System. drawing. drawing2d. lineargradientbrush brush = new system. drawing. drawing2d. lineargradientbrush (New rectangle (0, 0, image. width, image. height), color. white, color. red, (float) 1.2f, true );
G. drawstring (PV, Font, brush, 0, 0 );
G. drawrectangle (new pen (color. Gold), 0, 0, image. Width-1, image. Height-1 );
System. Io. memorystream MS = new system. Io. memorystream ();
Image. Save (MS, system. Drawing. imaging. imageformat. GIF );
Response. clearcontent ();
Response. contenttype = "image/GIF ";
Response. binarywrite (Ms. toarray ());
}
}
Method 3:
Static Page statichtml.html Copy code The Code is as follows: <! 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> several methods for collecting dynamic page access volume </title>
</Head>
<Body>
This is implemented using Ajax.
<Div id = "ajaxpv"> </div>
<Script language = "JavaScript" type = "text/JavaScript">
Function addpv (){
// Create a cross-browser XMLHTTPRequest object
VaR XMLHTTP;
Try {
XMLHTTP = new activexobject ('msxml2. xmlhttp ');
} Catch (e ){
Try {
XMLHTTP = new activexobject ('Microsoft. xmlhttp ');
} Catch (e ){
Try {
XMLHTTP = new XMLHttpRequest ();
} Catch (e ){}
}
}
// Create a request
XMLHTTP. Open ("get", "ajaxpv. aspx? News = 1 ");
XMLHTTP. onreadystatechange = function (){
If (XMLHTTP. readystate = 4 ){
If (XMLHTTP. Status = 200 ){
// Determine whether the user name exists based on responsetext
VaR repv = XMLHTTP. responsetext;
VaR mypv = Document. getelementbyid ("ajaxpv ");
Mypv. innerhtml = repv;
/* Alert (repv );*/
} Else {
Alert ("Network failed. ");
}
}
};
XMLHTTP. Send (null );
Window. setTimeout ("addpv", 1000 );
}
Window. onload = addpv;
</SCRIPT>
</Body>
</Html>
Accumulate page ajaxpv. aspxCopy codeThe Code is as follows: <% @ page Language = "C #" autoeventwireup = "true" codefile = "ajaxpv. aspx. cs" inherits = "ajaxpv" %>
ajaxpv. aspx. CS copy the Code the code is as follows: public partial class ajaxpv: system. web. UI. page
{< br> Private Static int COUNT = 1;
protected void page_load (Object sender, eventargs E)
{< br> // accumulate data to the database
// read data from the database. Currently,
COUNT = 5;
response. write (count);
}< BR >}