<newbie> problem with updatepanel and trigger

J

Jeff

hi

asp.net 3.5 (project upgraded from asp.net 2.0).
are using vwd2008 express now

This is my first ajax attempt. The code below shows a TextBox and a ListBox.
The idea I was trying to accomplish was that the items in the ListBox was
automatically filtered as the user type text into the textbox... But nothing
happens. The OnTextChanged event isn't even fired when I type in the
textbox.

Any suggestions?

<table style="width: 100%;">
<tr>
<td>
<asp:TextBox ID="txtTextBox1" Width="190"
OnTextChanged="OnTextChanged" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/Images/Go.gif" />
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox Width="200" ID="ListBox1" runat="server">
</asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtTextBox1"
EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
 
B

bruce barker

OnTextChanged is a serverside event. it will only be fired on a
postback. you can put autopostback on a textbox to auto fire a postback,
but this will only happen when the client side onblur happens (focus
leaves textbox).

to reload the listbox as the users types will require you write client
script that is attached to the clientside onkeypress event. this code
should then do an ajax call to update the list. the update panel is
probably overkill for this, I'd just have the javascript do a webservice
call and reload the list in client script.

google combobox controls and you will get a lot of sample javascript.
the ajax control toolkit has similar control. this would probably be
covered in any javascript book.

-- bruce (sqlwork.com)
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top