IT Community - Software Programming, Web Development and Technical Support

Listbox onselected event problem

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-31-2007, 02:42 AM
$enthil $enthil is offline
D-Web Sr.Programmer
 
Join Date: Apr 2007
Posts: 162
$enthil is on a distinguished road
Smile Listbox onselected event problem

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:
<asp:ListBox ID="ListBox1" runat="server" Height="167px" Width="250px" OnSelectedIndexChanged="ListBox1_SelectedIndexChan ged" ></asp:ListBox>
__________________
$enthil
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-31-2007, 04:32 AM
it.wily it.wily is offline
D-Web Programmer
 
Join Date: Jul 2007
Posts: 89
it.wily is on a distinguished road
Smile Re: Listbox onselected event problem

Try this code:
Quote:
<asp:ListBox ID="ListBox1" runat="server" Height="167px" Width="250px" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChan ged" ></asp:ListBox>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-01-2007, 10:36 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Smile Re: Listbox onselected event problem

<% @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>
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 06:31 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0