Listbox onSelectedIndexChanged event firing on Page Load

Discussion in 'ASP .Net' started by =?Utf-8?B?UmVkR1NU?=, Mar 15, 2005.

  1. 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?
    =?Utf-8?B?UmVkR1NU?=, Mar 15, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?UmVkR1NU?=

    Karl Seguin Guest

    Seems odd...could you simplify the page and include all the ASPX and
    codebehind? My guess is that something in Init is wrongly hooked up....

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is
    annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)
    "RedGST" <> wrote in message
    news:...
    > 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?
    Karl Seguin, Mar 15, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julie Barnet

    OnSelectedIndexChanged not firing

    Julie Barnet, Aug 20, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    8,978
    Yusuf D M
    Aug 21, 2003
  2. Paul L
    Replies:
    1
    Views:
    7,295
  3. GauravGupta
    Replies:
    4
    Views:
    2,099
    Shilpa1234
    Jan 19, 2012
  4. Jerry

    DropDownList - onSelectedIndexChanged not firing

    Jerry, Apr 15, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    191
    Jerry Higgins
    Apr 16, 2004
  5. Paul L
    Replies:
    0
    Views:
    250
    Paul L
    May 5, 2005
Loading...

Share This Page