Using Javascript to detect when a user has selected an item in an ASP.NET listbox

Posted by Amr Bekhit on Stack Overflow See other posts from Stack Overflow or by Amr Bekhit
Published on 2010-03-16T17:15:20Z Indexed on 2010/03/16 17:21 UTC
Read the original article Hit count: 531

Filed under:
|
|
|

Hello all,

I am developing an ASP.NET web application that incorporates google maps. I have an ASP.NET listbox on my page which contains a list of items. When the user selects one of the items, I'd like to show this item on the map. The main complication lies in the fact that google maps uses javascript to control it and the listbox is a server control.

I can think of two ways to do this. The first would involve the listbox calling a javascript function when the user selects a new item. I can then write this function to perform the necessary map operations. Unfortunately, the OnSelectedIndexChanged property of the listbox doesn't seem to support javascript functions.

The second involves wrapping an UpdatePanel around the listbox and getting the listbox to perform a postback. In the SelectedIndexChanged event in VB/C#, I would the need to somehow make a call to a javascript function which would then update the map.

Which solution can I use?

Thanks

--Amr

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ASP.NET