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
Solved

Listbox javascript selectindex

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

808 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