Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > how to raise SelectedIndexChange event?

Reply
Thread Tools

how to raise SelectedIndexChange event?

 
 
Dave
Guest
Posts: n/a
 
      06-10-2006
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:
<aspropDownList ID="DropDownList1" runat="server">
</aspropDownList>

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


 
Reply With Quote
 
 
 
 
Bruno Alexandre
Guest
Posts: n/a
 
      06-10-2006
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:
<aspropDownList ID="DropDownList1" runat="server"></aspropDownList>

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:

<aspropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
OnSelectIndexChange="DropDownList1_SelectedIndexCh anged"></aspropDownList>

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" <(E-Mail Removed)> escreveu na mensagem
news:O8XO%(E-Mail Removed)...
> 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:
> <aspropDownList ID="DropDownList1" runat="server">
> </aspropDownList>
>
> 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
>
>



 
Reply With Quote
 
 
 
 
Dave
Guest
Posts: n/a
 
      06-10-2006
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" <(E-Mail Removed)> wrote in message
news:%23bv%(E-Mail Removed)...
> 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:
> <aspropDownList ID="DropDownList1" runat="server"></aspropDownList>
>
> 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:
>
> <aspropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
>

OnSelectIndexChange="DropDownList1_SelectedIndexCh anged"></aspropDownList>
>
> 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" <(E-Mail Removed)> escreveu na mensagem
> news:O8XO%(E-Mail Removed)...
> > 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:
> > <aspropDownList ID="DropDownList1" runat="server">
> > </aspropDownList>
> >
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
"raise (type, value, traceback)" and "raise type, value, traceback" Jack Bates Python 0 05-02-2011 05:23 PM
raise Exception or raise Exception() ernest Python 2 11-14-2010 08:14 PM
raise or not to raise [Newbie] Jacol Python 5 02-05-2007 11:46 PM
how to raise SelectedIndexChange event? Dave ASP .Net 2 06-10-2006 02:34 PM



Advertisments