473,405 Members | 2,187 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,405 software developers and data experts.

how to raise SelectedIndexChange event?

Hello,

I'm starting with asp.net and i don't know how to raise the
SelectedIndexChange event when clicking in a dropdownlist control.
I thought it was the same as by clicking on a button.

This is what i did:
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>

In the code-behind:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
response.write("test ok")
end sub

But nothing happens when clicking in the dropdownlist.
I probably miss some code ...

Any help woul be appreciated
Dave
Jun 10 '06 #1
2 2849
you can do that in two ways:
the simplest ( using the Design View ) click one time in the DropDownList, in Properties Window there is a
orange lighting icon (Events), click it
then you can see what events can you add to that components (in this
case the DropDownList)
to add a event click twice in one of then...
writting code ( using the Code View ) your code is actualy almost done, except that you miss one important
thing and one less important but for what you wan to do, extermelly
important.

your code is:
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>

as you can see, you are not telling the component to do anything! so you
need to tell him that you want to perform a function and if you want to
perform such function everytime you change the options in the DropDown you
need to tell him to perform an autopostbask, so the correct code will be
like this:

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
OnSelectIndexChange="DropDownList1_SelectedIndexCh anged"></asp:DropDownList>

you can remove the Handles DropDownList1.SelectedIndexChanged from the
function if you add the OnSelectIndexChange, or keep it and remove the event
from the ddl compont

hope that helps.
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Dave" <xc*@sdv.sdv> escreveu na mensagem
news:O8****************@TK2MSFTNGP03.phx.gbl... Hello,

I'm starting with asp.net and i don't know how to raise the
SelectedIndexChange event when clicking in a dropdownlist control.
I thought it was the same as by clicking on a button.

This is what i did:
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>

In the code-behind:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
response.write("test ok")
end sub

But nothing happens when clicking in the dropdownlist.
I probably miss some code ...

Any help woul be appreciated
Dave

Jun 10 '06 #2
Thanks for replying, but my mistake was that the option "autopostback" was
set on "off" in the properties. I changed it to "on" and it works ...

"Bruno Alexandre" <br*********@gmail.com> wrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
you can do that in two ways:
the simplest ( using the Design View ) click one time in the DropDownList, in Properties Window there is a
orange lighting icon (Events), click it
then you can see what events can you add to that components (in this
case the DropDownList)
to add a event click twice in one of then...
writting code ( using the Code View )

your code is actualy almost done, except that you miss one important
thing and one less important but for what you wan to do, extermelly
important.

your code is:
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>

as you can see, you are not telling the component to do anything! so you
need to tell him that you want to perform a function and if you want to
perform such function everytime you change the options in the DropDown you
need to tell him to perform an autopostbask, so the correct code will be
like this:

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"

OnSelectIndexChange="DropDownList1_SelectedIndexCh anged"></asp:DropDownList>
you can remove the Handles DropDownList1.SelectedIndexChanged from the
function if you add the OnSelectIndexChange, or keep it and remove the event from the ddl compont

hope that helps.
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Dave" <xc*@sdv.sdv> escreveu na mensagem
news:O8****************@TK2MSFTNGP03.phx.gbl...
Hello,

I'm starting with asp.net and i don't know how to raise the
SelectedIndexChange event when clicking in a dropdownlist control.
I thought it was the same as by clicking on a button.

This is what i did:
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>

In the code-behind:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
response.write("test ok")
end sub

But nothing happens when clicking in the dropdownlist.
I probably miss some code ...

Any help woul be appreciated
Dave


Jun 10 '06 #3

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

Similar topics

1
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
0
by: Thorben | last post by:
Hello, how can I undo/cancel the SelectedIndexChange event of an Listview control? Thanks in advance Thorben
1
by: Paul C | last post by:
Can anyone tell me why I am getting 2 calls to my SelectedIndexChange event. public class Browse : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid DataGrid1; protected...
1
by: Jay | last post by:
I have dropdownlist in a usercontrol and selectedindexchange event captured. But Iam seeing fire twice. Thanks.
2
by: MBhat | last post by:
Hello, I have a dropdownlist server control.On selectedIndexChange I do some functionality. In addtion to this I need to check for something else. To do this I have to use javascript function to...
12
by: Vittorio Pavesi | last post by:
Hello, is it possible to manually raise the event Elapsed of the timer object ? Vittorio
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...
3
by: =?Utf-8?B?Ulc=?= | last post by:
I constructed a new Class with some private members. I would like an event to be raised on the moment the value of one of those private members is changed. How do I define an event for that...
5
by: Mike | last post by:
Hi group; Let say I have an object called Account, that raises an event called AccountLow with its owns EventArgs, and when this event gets raised, I will like to raise another custom...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
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...

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.