473,399 Members | 3,603 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,399 software developers and data experts.

No event fired when first item in dropdown select

I have an handler for the SelectedIndexChanged event of a dropdown box. I
have also set the AutoPostBack option to True. When you select any item
besides the first one, the event sucessfully fires. However, if you ever
(even after you have selected other options previously) select the first
option in the dropdown, the AutoPostBack fires(the page reloads), but the
event does not. This is the only element on my page and ViewState is enabled
for both the page and the dropdown control.

Whats the deal here?
Nov 17 '05 #1
2 3214
Yup, this is a pain. Since you haven't changed the selection, the index hasn't
changed. Some people add a "---Select---" field to force users to make a move.

Ken

--
Microsoft MVPs have a question for *you*: Are you patched against the Worm?
http://www.microsoft.com/security/se...s/ms03-026.asp

"hypomite" <jo**@zgn.net> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I have an handler for the SelectedIndexChanged event of a dropdown box. I
have also set the AutoPostBack option to True. When you select any item
besides the first one, the event sucessfully fires. However, if you ever
(even after you have selected other options previously) select the first
option in the dropdown, the AutoPostBack fires(the page reloads), but the
event does not. This is the only element on my page and ViewState is enabled
for both the page and the dropdown control.

Whats the deal here?

Nov 17 '05 #2
Here's a great solution to this problem:

Use the required field validator.

First give your drop down list a first value like: "Please Select"

DropDownList1.Items.Insert(0, "Please Select") '---If you need to add it
after a databind.

Set the required field validator to validate the drop down.

Set the required field validator's InitialValue property to the initial
text: "Please Select"

The only thing is if the drop down is set to autopost back then the
validator won't fire on the client side so in your selected index changed
handler use:

Page.Validate()

If Page.IsValid Then

'---Code to run when drop down list is changed.

End If

Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Yup, this is a pain. Since you haven't changed the selection, the index hasn't changed. Some people add a "---Select---" field to force users to make a move.
Ken

--
Microsoft MVPs have a question for *you*: Are you patched against the Worm? http://www.microsoft.com/security/se...s/ms03-026.asp

"hypomite" <jo**@zgn.net> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I have an handler for the SelectedIndexChanged event of a dropdown box. I
have also set the AutoPostBack option to True. When you select any item
besides the first one, the event sucessfully fires. However, if you ever
(even after you have selected other options previously) select the first
option in the dropdown, the AutoPostBack fires(the page reloads), but the
event does not. This is the only element on my page and ViewState is enabled for both the page and the dropdown control.

Whats the deal here?

Nov 17 '05 #3

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

Similar topics

1
by: zfeld | last post by:
I need an event notification when the user types anything in the combobox textfield? I know about the TextChanged Event but the problem is this is also fired when the user selects an item in the...
3
by: DesignerX | last post by:
I have a dynamically created composite server control. The composite control contains a dropdownlist, a validator and a label. I have the dropdownlist AutoPostBack set to true and have defined...
12
by: moondaddy | last post by:
I have a dropdown combo box on a form and I have its AutoPostBack property set to true. When I select something from the list it does a postback and then the Page_Load event fires followed by it's...
0
by: Leonardo Santos-Macias | last post by:
I have a dropdown list that I bind at runtime. It does postback to the server. If I select any item, it will trigger the SelectedIndexChange event. My problem is that it doesn't trigger the...
2
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine...
5
by: docw | last post by:
SelectionChangeCommitted event fires twice Hi, Please have a look at the following ComboBox behavior. With the code below, if you click in the dropdown list with the mouse to select an item ,...
5
by: jaysonnward | last post by:
Hello All: I've recently been recreating some 'dropdown menus' for a website I manage. I'm writing all my event handlers into my .js file. I've got the coding to work in Firefox, but the...
11
by: J055 | last post by:
Hi I have a dropdown control which is constructed in another dropdown control SelectedIndexChanged event protected void ddlParamType_SelectedIndexChanged(object sender, EventArgs e) { //...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.