Solved

Listbox javascript selectindex

Posted on 2009-04-02
4
268 Views
Last Modified: 2012-05-06
hi every one,

Can someone help me with Javascript codes?  I have a databound listbox. I would like to do a javascript so that when user click on an item, it will pass that item value to a gridview.  I don't want to do Autopostback with my listbox because it create problem with my Listsearch_Extender

Thank you so much
*** added .NET and pushed the request attention link *** mplungjan, ee ZAPE

Open in new window

0
Comment
Question by:luubi
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 24058491
Do you mean something like this:


<asp:ListBox ID="ListBox1" runat="server" >
  <asp:ListItem>a</asp:ListItem>
  <asp:ListItem>b</asp:ListItem>
  <asp:ListItem>c</asp:ListItem>
</asp:ListBox>
Add a javascript function
 function Selection()
{
  alert(List.options[List.selectedIndex].value);
}
Then in code behind ,  
 
ListBox1.Attributes.Add("onchange", "Selection(this);");

Open in new window

0
 
LVL 21

Expert Comment

by:MogalManic
ID: 24058495
but I don't know what you mean by "pass that item value to a gridview"
0
 

Author Comment

by:luubi
ID: 24059323
I have a listbox databound listing of all the Project #.  Then, when a user click on the Project #, it will pass the value to a gridview to view all the tasks available for that Project.

I would like to do this with JS script instead of Auto Postback because when I turn on AutoPostback for listbox, my listsearch_extender does not work

Thanks
0
 

Accepted Solution

by:
luubi earned 0 total points
ID: 24169932
can someone help me with this?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question