Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Listbox onSelectedIndexChanged event firing on Page Load

 
Thread Tools Search this Thread
Old 03-15-2005, 04:03 PM   #1
Default Listbox onSelectedIndexChanged event firing on Page Load


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?=
  Reply With Quote
Old 03-15-2005, 05:50 PM   #2
Karl Seguin
 
Posts: n/a
Default Re: Listbox onSelectedIndexChanged event firing on Page Load
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:BEBC88E1-17B8-4BD2-9F5E-...
> 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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Asynchronous process from asp.net page button click event? Ritha Software 0 09-29-2009 03:20 PM
Load .aspx page on another frame from TreeView Event Sangeeth Software 0 06-25-2009 09:20 AM
master page does not change due to preinit event not firing franchise63 General Help Related Topics 0 02-13-2008 09:18 AM
How to load Two iframe in one aspx page? pratima Software 2 02-02-2008 03:17 AM
Don't want to load the page everytime when I clicked on any ImageButton in DataList tapasmahata Software 0 01-18-2008 08:45 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46