Thursday, March 22, 2012

listbox click - nothing happens?

Hi,
I open up a webform (vb.net) and populate a listbox
control on the Page load event. If I click on (select)
and item from the listbox I want to write the value of the
selected item to a label control. Nothing happens. But
when I click a button (which contains same code to write
to label) I get the value of the selected item in the
Label.
I looked at the html portion of my webform and don't see a
listing for the onclick event of the button. So, do I
need to manually enter the "SelectedIndexChanged" event in
the html for the listbox?
<asp:listbox id="lstProducts" style="Z-INDEX: 101; LEFT:
48px; POSITION: absolute; TOP: 80px"runat="server"
Height="192px" Width="400px"></asp:listbox>
Thanks,
SteveYes, you do. You need to set the listbox's AutoPostBack property to true
and hook up the SelectedIndexChange event to a method.
Karl
"Steve" <anonymous@.discussions.microsoft.com> wrote in message
news:94a901c4863c$a99b3f20$a501280a@.phx.gbl...
> Hi,
> I open up a webform (vb.net) and populate a listbox
> control on the Page load event. If I click on (select)
> and item from the listbox I want to write the value of the
> selected item to a label control. Nothing happens. But
> when I click a button (which contains same code to write
> to label) I get the value of the selected item in the
> Label.
> I looked at the html portion of my webform and don't see a
> listing for the onclick event of the button. So, do I
> need to manually enter the "SelectedIndexChanged" event in
> the html for the listbox?
> <asp:listbox id="lstProducts" style="Z-INDEX: 101; LEFT:
> 48px; POSITION: absolute; TOP: 80px"runat="server"
> Height="192px" Width="400px"></asp:listbox>
> Thanks,
> Steve

0 comments:

Post a Comment