Showing posts with label box. Show all posts
Showing posts with label box. Show all posts

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

Monday, March 26, 2012

ListBox control with AJAX

HI,

I have three listboxes on a .aspx 2.0 Framework web page. When selection(s) are made in 1st list box the next two list boxes will change accordingly, and when selection(s) are made in 2nd listbox third list box will change, and this can be other way around. My problem is how do i apply Atlas toolkit's extenders to this, or how do i impletement this with ASP.NET AJAX. Any help is really really appreciated.

sirulu

Hi All,

I am also having the same problem.

I am implementing the AJAX Toolkit control in web application.
In my web application i have the folowing scenario:

Select Country from Dropdownlist

Select State from Dropdownlist

Select multiple Cities from Listbox

But i am not able to use List Box control with the AJAX cascading drop down extender.

Please let me know how to use List Box control with the AJAX cascading drop down extender.

Thanks in advance.


Regards,
Sudhir Kumar


Hi All,

I am implementing the AJAX Toolkit control in web application.
In my web application i have the folowing scenario:

Select Country from Dropdownlist

Select State from Dropdownlist

Select multiple Cities from Listbox

But i am not able to use List Box control with the AJAX cascading drop down extender.

Please let me know how to use List Box control with the AJAX cascading drop down extender.

Thanks in advance.


Regards,
Sudhir Kumar

listsearch

I have put a list box search extender control on my page. It works great except for two things. First if I click in the list box it activates the index change and that may not be data field I wanted. Two when using the search option and I found the record I wanted. The record was highlighted and when I clicked on it nothing happens. I can click on other fields and the list box works great. I need some help.

when i select an item by the listseach the selecteditemchanged event doesn't works


Ajax ListSearchExtender does not force its targeted DropDownList to postback once the desired item has been selected.

You need to write a javascript to force the DropDownList to postback once it loses its focus.

I had the same problem and here's how I got around to it.

ASP

<asp:DropDownList ID="ddl_LocationID" runat="server" AutoPostBack="True" Width="200"

OnSelectedIndexChanged="ddl_LocationID_SelectedIndexChanged"

OnLoad="ddl_LocationID_Load"></asp:DropDownList>

Code Behind

protected void ddl_LocationID_Load(object sender, EventArgs e)
{
string script = ClientScript.GetPostBackEventReference(ddl_LocationID, "");
ddl_LocationID.Attributes.Add("onblur", script);
}

protected void ddl_LocationID_SelectedIndexChanged(object sender, EventArgs e)
{
// Do something when an item has been selected
}


Lonnie, try this:

HTML

<script type="text/javascript">function UpdateLabel(){var btn = $get("ctl00_MainContent_btnTest");if(btn != null) { btn.click(); }}</script><asp:UpdatePanel ID="ListBox_UpdatePanel" UpdateMode="Conditional" runat="server"><ContentTemplate><asp:ListBox ID="ListBox1" onclick="UpdateLabel();" runat="server"><asp:ListItem Text="Item 1" Value="1" Selected="true" /><asp:ListItem Text="Item 2" Value="2" /><asp:ListItem Text="Item 3" Value="3" /><asp:ListItem Text="Item 4" Value="4" /><asp:ListItem Text="Item 5" Value="5" /></asp:ListBox><asp:Label ID="lblItem" runat="server" /><asp:Button ID="btnTest" Text="Update Label" OnClick="UpdateLabel" runat="server" /><ajaxToolkit:ListSearchExtender ID="lseListBox1" TargetControlID="ListBox1" runat="server" /></ContentTemplate></asp:UpdatePanel>

Code Behind:

Protected Sub UpdateLabel(ByVal senderAs Object,ByVal eAs EventArgs)Me.lblItem.Text =Me.ListBox1.SelectedValueEnd Sub

fikreter, you need to put AutoPostBack="true" on your listbox:

Let me know if any of you need further help ...


The latest toolkit release containts an updated version of the ListSearch Extender which will fire an OnChange (and therefore postbacks) when the target List loses focus (if you Tab or click away), or if you hit Enter.

Regards,

Damian