别调用页面 Diagnostics.aspx 代码

 1using System.Diagnostics;
 2
 3public partial class _Default : System.Web.UI.Page 
 4{
 5    protected void Page_Load(object sender, EventArgs e)
 6    {
 7        PerformanceCounter myMemory = new PerformanceCounter();
 8        myMemory.CategoryName = "Memory";
 9        myMemory.CounterName = "Available KBytes";
10        string txtResult = "--->当前可用内存:" + myMemory.NextValue().ToString() + "KB";
11        Response.Write(DateTime.Now.ToLongTimeString() + txtResult);
12    }

13}


接受页代码 Client.htm 代码

 1    <script type="text/javascript">
 2        var XmlHttp=new ActiveXObject("Microsoft XMLhttp");
 3        
 4        function sendAJAX()
 5        {
 6            XmlHttp.Open("POST","Diagnostics.aspx",true);
 7            XmlHttp.send(null);
 8            XmlHttp.onreadystatechange=ServerProcess;
 9        }

10        function ServerProcess()
11        {
12            if(XmlHttp.readystate==4 || XmlHttp.readystate=="complete")
13            {
14                document.getElementById("nameList").innerHtml=XmlHttp.responsetext;
15            }

16        }

17        setInterval("sendAJAX()",1000);
18    </script>
19</head>
20<body>
21<div id="nameList"></div>
22</body>




posted on 2006-12-28 01:23  小角色  阅读(275)  评论(0)    收藏  举报