Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:ListBox runat="server" ID="myListBox" OnSelectedIndexChanged="myListBox_SelectedIndexChanged" Height="102px"
    Width="102px" >
    <asp:ListItem Text="ListBox1" Value="MyListBoxa"></asp:ListItem>
    <asp:ListItem Text="ListBox2" Value="MyListBoxad"></asp:ListItem>
    <asp:ListItem Text="ListBox3" Value="MyListBoxf"></asp:ListItem>
    <asp:ListItem Text="ListBox4" Value="MyListBoxc"></asp:ListItem>
</asp:ListBox<asp:Label ID="Label1" runat="server" Text="Label"/>


C#
protected void myListBox_SelectedIndexChanged(object sender, EventArgs e)
{
    //Response.Write(this.myListBox.SelectedItem.ToString());
    this.Label1.Text = "hello world";

}


When I run this program in my VM, there is nothing in web page.
Could you help me? THS.
Posted
Comments
janwel 15-Aug-11 1:36am    
please mark solution if any of the answer below has solved your problem. thanks

set AutoPostBack="true" 
 
Share this answer
 
ASP.NET
</asp:ListBox<asp:Label ID="Label1"  runat="server" Text="Label"/> 


This line is missing a closing bracket after ListBox. This is therefore malformed, and probably won't work at all.
 
Share this answer
 
v2
<asp:ListBox runat="server" ID="myListBox" OnSelectedIndexChanged="myListBox_SelectedIndexChanged" Height="102px"
Width="102px" >
<asp:ListItem Text="ListBox1" Value="MyListBoxa"></asp:ListItem>
<asp:ListItem Text="ListBox2" Value="MyListBoxad"></asp:ListItem>
<asp:ListItem Text="ListBox3" Value="MyListBoxf"></asp:ListItem>
<asp:ListItem Text="ListBox4" Value="MyListBoxc"></asp:ListItem>
</asp:ListBox>

<asp:Label ID="Label1" runat="server" Text="Label"/>




Your closing tag to listbox control was not proper.Refer the above code for help.



Hope this will help you
 
Share this answer
 
Thanks for your help.
I am a enter.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900