Wednesday, March 28, 2012

List Box and the update panel

I would like to know the event name to use when an ASP List Box is used with the update panel control. I would like the updatePanel to fire when the ListBox Selected Index Changed event occurs.

Thank You for any help

George

<asp:ListBoxID="ListBox1"runat="server"DataSourceID="AccessDataSource1"DataTextField="product_name"DataValueField="product_id"Rows="30"CausesValidation="True"></asp:ListBox>

<asp:AccessDataSourceID="AccessDataSource1"runat="server"DataFile="~/App_Data/test.mdb"SelectCommand="SELECT [product_id], [product_name] FROM [Products]"></asp:AccessDataSource>

<asp:ButtonID="Button1"runat="server"Text="Button"/>

<atlas:UpdatePanelID="up222"Mode="Conditional"runat="server">

<Triggers>

<atlas:ControlEventTriggerControlID="ListBox1"EventName="SelectedIndexChanged"/> <!-- DOES NOT FIRE -->

<atlas:ControlEventTriggerControlID="Button1"EventName="Click"/>

</Triggers>

<ContentTemplate>

<asp:LabelID="Label2"runat="server"Text="Labe354"></asp:Label>

</ContentTemplate>

</atlas:UpdatePanel>

You have everything exactly right, though it might not actually be what you want. Every time the SelectedIndexChanged event is raised, or the button is clicked, the UpdatePanel will be updated. However, to get any of that to happen, a postback must occur. In your sample page, the only way to get that to happen is to click the button. To make the page update immediately when the list selection changes, add this property to your ListBox: AutoPostBack="true"

Thanks,

Eilon

No comments:

Post a Comment