Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I was wondering if someone could give me a hand in this project that im working on, right now i need to auto-select the first item on a listbox after i click an item on a diferent listbox.

Im working in Aspx , thank you.

Best Regards
Posted

Hi ,
If you need to select the First Value you have to set SelectedIndex
C#
ListBox1.SelectedIndex = 0;

Best Regards
M.Mitwalli
 
Share this answer
 
Comments
Member 8956437 24-May-12 4:56am    
I see, thank you, but how do i apply that to Aspx?
Mohamed Mitwalli 24-May-12 7:48am    
just put it in page load
Member 8956437 24-May-12 7:57am    
I've tried that but its not workig, nothing that i put in Page_load works.
C#
ListBox1.SelectedIndex = 0;


is the right answer and you should write in in C# code.

if you want to use JS

then you can use
JavaScript
document.getElementById("ListBox1").selectedIndex = 0;


at then bottom of page
 
Share this answer
 
Comments
Member 8956437 24-May-12 5:24am    
I put that in protected void Page_Load(object sender, EventArgs e) and its not working. Im kinda new to Aspx an Aspx.Cs
Technoses 24-May-12 12:55pm    
what is your code write here bolow
Member 8956437 24-May-12 13:02pm    
I dont have any code in the aspx.cs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900