Listbox onSelectedIndexChanged event firing on Page Load

G

Guest

Hello,
Im somewhat new to asp.net, so bear with me.

I have created a form that has a Listbox along with 2 command buttons & a
few other non-important controls.

The command button is tied to the OnClick Event.

My problem is that when the command button is clicked, the Listbox
OnSelectedIndexChanged event gets fired before the command buttons OnClick
Event.
(I have validated the process through the debugger)

The PostBack process goes:
1. Page_Load
2. ListBox_OnSelectedIndexChanged
3. cmdSubmit_OnClick.

My Page_Load does nothing to change the listbox selections.

Also, when I first load the page, the OnSelectedIndexChanged event doesnt
get fired (which i figure to be correct) - so I figured this to be the same
as after the cmdSubmit button was pressed (since there is no activity
happening on the Listbox)

Here is my Page_Load code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Add the javascript validation for the Delete
cmdDelete.Attributes.Add("onClick", "return confirmDelete();")

' This is only processed on initial page load.
If Not IsPostBack Then
SetUpHelpfulHints()
SetUpCalendars()
SetUpForm(0)
End If
End Sub.

Why is the listbox onSelectedIndexChange Event fired?
Even with that, why is it fired before the button's OnClick event?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top