473,695 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

No event fired when first item in dropdown select

I have an handler for the SelectedIndexCh anged 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 3245
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******** *******@tk2msft ngp13.phx.gbl.. .
I have an handler for the SelectedIndexCh anged 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.I tems.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******** *******@TK2MSFT NGP09.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******** *******@tk2msft ngp13.phx.gbl.. .
I have an handler for the SelectedIndexCh anged 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
10395
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 combobox which updates the textfield, and there is no way of knowing what fired the event other then that it came from the combobox. I am guessing the only way to do this would involve the keyup & keydown events. How about if the user pastes...
3
9771
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 a handler for the SelectedIndexChanged event. The server control is instantiated upon every request. It currently adds 2 items to the dropdownlist from the database.
12
3986
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 SelectedIndexChanged event. However, when I go back to this control again and select the first item in the list, it does a postback and the Page_Load event fires, but the SelectedIndexChanged doesn't fire. Why does the SelectedIndexChanged get...
0
1065
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 SelectedIndexChange event when I select the first item (index=0)... any ideas? The dropdown lives in a custom control
2
16092
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 in my asp tag as shown here: <asp:DropDownList id="ddlTo" runat="server"
5
6805
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 , everything is fine. But if you use the Enter key to select in the dropdown list, the SelectionChangeCommitted event is fired twice.
5
4539
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 onmouseleave / onmouseout event I've attached to my hidden drop down (in this case an <ul>), is not firing correctly. It seems that when the mouse enters the ul it fires the mouseleave event. The problem is in the hideMenu2(e) function. I'm copying...
11
36984
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) { // some other code DropDownList ddlGroups = new DropDownList(); ddlGroups.SelectedIndexChanged += new
0
8647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8585
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9004
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8864
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4351
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4592
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3024
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2288
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.