Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Professional ASP.NET 3.5 in C# and Visual Basic Part 152. Building on the revolutionary ASP.NET 2.0 release, ASP.NET 3.5 adds several key new developer features including AJAX, LINQ, and a new CSS designer in Visual Web Developer 2008. The dramatic reduction in code that developers realized from the more than 50 new server controls in ASP.NET 2.0 now allows developers the time to make their applications more interactive with AJAX, to work with data in their preferred language with LINQ, and to build visually attractive and consistent standards-based sites with CSS | Chapter 32 Instrumentation void DisplayInstances PerformanceCounterCategory pcc List string listPcc new List string foreach string item in pcc.GetInstanceNames listPcc.Add item.ToString listPcc.Sort DropDownList3.DataSource listPcc DropDownList3.DataBind protected void DropDownList1_SelectedIndexChanged object sender EventArgs e PerformanceCounterCategory pcc pcc new PerformanceCounterCategory DropDownList1.SelectedItem.Text DropDownList2.Items.Clear DropDownList3.Items.Clear DisplayCounters pcc protected void Button1_Click object sender EventArgs e PerformanceCounter pc if DropDownList3.Items.Count 0 pc new PerformanceCounter DropDownList1.SelectedItem.Text DropDownList2.SelectedItem.Text DropDownList3.SelectedItem.Text else pc new PerformanceCounter DropDownList1.SelectedItem.Text DropDownList2.SelectedItem.Text Label1.Text b Latest Value b pc.NextValue .ToString script To make this work you have to deal with only a couple of performance-counter objects such as the PerformanceCounterCategory and the PerformanceCounter objects. The first drop-down list is populated with all the categories available. These values are first placed in a List of String object that enables you to call a Sort method and also allows you to remove any categories you aren t interested in by using the Remove method before binding to the DropDown list control. The category selected in the first drop-down list drives what is displayed in the second and third dropdown lists. The second drop-down list displays a list of counters that are available for a particular category. You might tend to think that the third drop-down list of instances is based upon the counter that is selected but instances are set at the category level. 1475 Chapter 32 Instrumentation When the button on the page is clicked a new instance of the Performancecounter object is created and as you can see from the example it can be instantiated in several ways. The first constructor takes just a category name and a counter name