This is a discussion on Listbox onselected event problem within the ASP and ASP.NET Programming forums, part of the Web Development category; I have created a listbox in my aspx page such that the list box have to call ListBox1_SelectedIndexChanged() in server ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| I have created a listbox in my aspx page such that the list box have to call ListBox1_SelectedIndexChanged() in server side when selecting any of the items in the listbox. But the function is not triggerred. Here is my code: Quote:
__________________ $enthil |
| Sponsored Links |
| |||
| Try this code: Quote:
|
| |||
| <% @Page Language="C#" %> <% @Import Namespace="System.Diagnostics" %> <% @Import Namespace="System.Collections" %> <html> <head> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { } void OnCounterInfo(Object sender, EventArgs e) { string strCategory = Category.SelectedItem.Value; CounterInstances.Items.Clear(); PerformanceCounterCategory pcCat = new PerformanceCounterCategory(strCategory); string[] arrInstanceNames = pcCat.GetInstanceNames(); if (arrInstanceNames.GetLength(0) > 1) { CounterInstances.DataSource = arrInstanceNames; CounterInstances.DataBind(); } } void SubmitBtn_Click(Object sender, EventArgs e) { string strCat = Category.SelectedItem.Value; string strCounter = Counters.SelectedItem.Value; string strInstance = ""; if (CounterInstances.Items.Count > 0) strInstanceName = CounterInstances.SelectedItem.Value; PerformanceCounter pc = new PerformanceCounter(strCat, strCounter, strInstance); float dResult = pc.NextValue(); Message.Text = "<" + strCat + "> [" + strCounter + "] {" + strInstance + "} = " + dResult.ToString(); } </script> </head> <body> <h3>Performance Counter Help</h3> <form runat="server" method="post"> <table width="400"> <tr><td>Category:</td><td>Counter:</td><td>Instances</td></tr> <tr><td valign="top"> <asp:dropdownlist id="Category" AutoPostBack="True" DataTextField="CategoryName" DataValueField="CategoryName" runat=server OnSelectedIndexChanged="OnDisplayCategory" /> </td><td valign="top"> <asp:ListBox id="Counters" Width="200px" runat="server" DataTextField="CounterName" DataValueField="CounterName" AutoPostBack="True" OnSelectedIndexChanged="OnCounterInfo"/> </td><td valign="top"> <asp:ListBox id="CounterInstances" Width="100px" runat="server" /> </td></tr> </table> <asp:button OnClick="SubmitBtn_Click" text="Lookup" runat="server"/> </form> </body> </html> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extracting specific elements from listbox | Kirubhananth | ASP and ASP.NET Programming | 5 | 04-08-2008 10:35 PM |
| How i will get the selected value from Listbox( if selection mode=multiple) | Mramesh | C# Programming | 3 | 02-07-2008 04:20 AM |
| How to Select a record using Listbox and edit/update it's fields using textboxes? | kingmaker | ASP and ASP.NET Programming | 1 | 12-19-2007 09:30 PM |
| ASP.net threading issue when populating a listbox | $enthil | ASP and ASP.NET Programming | 6 | 11-04-2007 11:24 PM |
| event.clientX and event.clientY is working in IE but not work in firefox? | senraj | HTML, CSS and Javascript Coding Techniques | 2 | 08-08-2007 05:27 AM |