<newbie> problem with updatepanel and trigger

Discussion in 'ASP .Net' started by Jeff, Nov 12, 2008.

  1. Jeff

    Jeff Guest

    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>
     
    Jeff, Nov 12, 2008
    #1
    1. Advertising

  2. Jeff

    bruce barker Guest

    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)


    Jeff wrote:
    > 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>
    >
    >
     
    bruce barker, Nov 12, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    492
    Rob Meade
    Aug 8, 2007
  2. =?Utf-8?B?Sm9l?=

    trigger updatepanel from gridview button

    =?Utf-8?B?Sm9l?=, Aug 8, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    716
    =?Utf-8?B?Sm9l?=
    Aug 8, 2007
  3. zb
    Replies:
    1
    Views:
    644
    PJ on Development
    Nov 8, 2007
  4. Replies:
    1
    Views:
    420
    Braulio Diez
    Dec 11, 2007
  5. Nathan Sokalski
    Replies:
    1
    Views:
    597
    miher
    Jun 15, 2009
Loading...

Share This Page