Solved

Listbox javascript selectindex

Posted on 2009-04-02
4
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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…
Suggested Courses

622 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