Problem with events, Anyone pls help

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
 
A

Andrew Morton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top