Problem with events, Anyone pls help

  • Thread starter Thread starter Vijay
  • Start date Start date
V

Vijay

hi,
I have a textbox, a listbox, two buttons in a page. I'm using this page to
add and remove cities. If I enter a character in the textbox , the items in
the list box must be filtered( Must show the city starting with the
character entered in the textbox and soon on).

If I press add button, the page must add the city to the list box. If I
press remove button, the selected item must be removed.

I'm using textbox_changed event to trigger the filtering process in the list
box.

The problem is whenever I press add button, textbox_changed event is called
and the value is not added to the listbox. Then when I press the add button
second time, then the value is added to the Listbox.

Anyone pls help

Thanks in Advance
Vijay chandar
 
Vijay said:
hi,
I have a textbox, a listbox, two buttons in a page. I'm using this
page to add and remove cities. If I enter a character in the textbox
, the items in the list box must be filtered( Must show the city
starting with the character entered in the textbox and soon on).

If I press add button, the page must add the city to the list box. If
I press remove button, the selected item must be removed.

I'm using textbox_changed event to trigger the filtering process in
the list box.

The problem is whenever I press add button, textbox_changed event is
called and the value is not added to the listbox. Then when I press
the add button second time, then the value is added to the Listbox.

At a guess, you are populating the city list box in the Page_Load handler.
This will be out of sequence for what you want - the view state takes care
of repopulating it. If that is the case then all you need to do is

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If Not(Page.IsPostBack) Then
populateCitiesList()
End If
End Sub

HTH,

Andrew
 
Back
Top