⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readcounters.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<%@ Import Namespace="System.Diagnostics" %>

<Script Runat="Server">

Sub Page_Load
  If Not IsPostBack Then
    Dim objCategory As PerformanceCounterCategory

    objCategory = New PerformanceCounterCategory( "ASP.NET Applications" )
    lstInstances.Datasource = objCategory.GetInstanceNames()
    DataBind()
  End If
End Sub

Sub SelectInstance( s As Object, e As EventArgs )
  Dim objCategory As PerformanceCounterCategory

  objCategory = New PerformanceCounterCategory( "ASP.NET Applications" )
  lstCounters.Visible = True
  lstCounters.Datasource = objCategory.GetCounters( lstInstances.SelectedItem.Text )
  lstCounters.DataTextField = "CounterName"
  DataBind()
End Sub

Sub SelectCounter( s As Object, e As EventArgs )
  Dim objCounter As PerformanceCounter

  objCounter = New PerformanceCounter( "ASP.NET Applications", _
    lstCounters.SelectedItem.Text, lstInstances.SelectedItem.Text )
  lblValue.Text = objCounter.NextValue()
End Sub
</Script>

<html>
<head><title>ReadCounters.aspx</title></head>
<body>

<h2>ASP.NET Application Performance Counters</h2>


<form Runat="Server">

<b>Instances</b>
<br>
<asp:ListBox
  ID="lstInstances"
  AutoPostback="True"
  OnSelectedIndexChanged="selectInstance"
  Runat="Server" />
<p>
<b>Counters</b>
<br>
<asp:ListBox
  ID="lstCounters"
  Visible="False"
  AutoPostback="True"
  OnSelectedIndexChanged="selectCounter"
  Runat="Server" />
<p>
<b>Counter Value:</b>
<asp:Label
  ID="lblValue"
  Runat="Server" />

</form>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -