473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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?
Nov 19 '05 #1
1 5028
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" <Re****@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com...
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?

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
6
by: Steve | last post by:
Hi, I open up a webform (vb.net) and populate a listbox control on the Page load event. If I click on (select) and item from the listbox I want to write the value of the selected item to a...
0
by: Stuart Allen | last post by:
I have a custom class that inherits System.Web.UI.Page for use with all my pages. On a page I'm trying to use a DropDownList. I have autopostback=true and have a method defined for the...
6
by: srallen | last post by:
I have a simple page that has a dropdown with autopostback=true and onselectedindexchanged is set to a function that never gets called (checked during debug). This page is subclassed from custom...
3
by: Raja | last post by:
I have a simple question, I have a datagrid and inside the grid, i have List box. I am able to render the page with the datagrid and the lisbox values. Now, my question is how to trap the server...
1
by: Paul L | last post by:
Hi, I have an issue with the OnSelectedIndexChanged event not firing for a DropDownList control which is in the ItemTemplate of a DataList. I have made an exact copy of the DropDownList control,...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
1
by: bigijoseph | last post by:
Please help : page load event is not firing. -------------------------------------------------------------------------------- Hi, I am a new to .net. I am trying to learn it. I tried the...
0
by: crespo | last post by:
hi,everyone. I have a question about using listbox in a customized user control.I use a listbox directly in a asp.net page and it works very well,but when I use the same code in a user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.