Solved

Listbox javascript selectindex

Posted on 2009-04-02
4
266 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now