get value of asp:ListBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi again!

Right, okay... im now trying to get the value of an <asp:TextBox> control.
so I have on my ASPX page...

<asp:ListBox id="results" runat="server"></asp:ListBox>
<asp:TextBox id="txtSelected" runat="server"></asp:TextBox>

In my code-behind Page_Load i have..
results.Items.Add("Dan");
results.Items.Add("Fred");

I double clicked the listbox and it the createdresults_SelectedIndexChanged
function for me, to which ive added...

txtSelected.Text = results.SelectedItem.Value;

It doesn't work! Tried various properties from ListBox, nothing seems to
work. It's not even refreshing the page. It just does nothing. Not sure if
it's the code or I've created the wrong function (maybe results_OnClick is
better?).

help :)

cheers


Dan
 
probably the control lost the attached event. So try to go control properties
to see if the control still have the events atacched. Or probably you didn't
set the property autopostback = true.
 
thanks mate - twas the postback! ill get used to it all eventually - sooo
different from asp :)
 
Back
Top