Home All Groups Group Topic Archive Search About

drop down list box - client side code won't execute OnSelectedIndexChange

Author
1 Dec 2005 6:55 PM
ezelasky
I am trying to get a client side javascript function to invoke when the
selection changes in a drop down list box.  I have tried :

ddl_specs.Attributes["language"] = "javascript";
ddl_specs.Attributes["OnSelectedIndexChanged"] = "return
OnChangeSpec();";

with & without the "return"; and with & without AutoPostBack = true on
the list box property and the javascript function just will not
execute.

I have gotten client side java script to work on an asp:button by
adding the javascript function via the attributes collection, so I am
not sure what else could be going on here.

Much Thanks.

Author
1 Dec 2005 8:19 PM
Phillip Williams
The client-side event name is "onchange", e.g.
ddl_specs.Attributes.Add ("onChange", "OnChangeSpec();");

SelectedIndexChanged is the server-side event which can be used as this:
ddl_specs.SelectedIndexChanged +=new
EventHandler(ddl_specs_SelectedIndexChanged);
Show quoteHide quote
"ezela***@hotmail.com" wrote:

> I am trying to get a client side javascript function to invoke when the
> selection changes in a drop down list box.  I have tried :
>
> ddl_specs.Attributes["language"] = "javascript";
> ddl_specs.Attributes["OnSelectedIndexChanged"] = "return
> OnChangeSpec();";
>
> with & without the "return"; and with & without AutoPostBack = true on
> the list box property and the javascript function just will not
> execute.
>
> I have gotten client side java script to work on an asp:button by
> adding the javascript function via the attributes collection, so I am
> not sure what else could be going on here.
>
> Much Thanks.
>
>
Author
1 Dec 2005 8:43 PM
ezelasky
Thanks!  Where  would I have found this? (besides posting the
question).
Author
1 Dec 2005 10:01 PM
Phillip Williams
You are welcome.

The ASP.NET web server controls render HTML objects on the browser. 
Therefore to manipulate any server control on the browser (using custom
JavaScript) one has to study the HTML objects that they render. For example
the DropDownList server control renders an HTML object named <SELECT> on the
browser.  By searching the MSDN for documentation on SELECT you would get its
properties and events:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/select.asp

Show quoteHide quote
"ezela***@hotmail.com" wrote:

> Thanks!  Where  would I have found this? (besides posting the
> question).
>
>
Author
2 Dec 2005 1:56 AM
Nathan Sokalski
There are probably many places, but here is one of my favorite sites as a
reference for Javascript code (and other languages commonly used on the
web):

http://www.devguru.com/Technologies/ecmascript/quickref/js_eventhandler.html

Good luck!
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/
<ezela***@hotmail.com> wrote in message
Show quoteHide quote
news:1133469816.372181.110250@g14g2000cwa.googlegroups.com...
> Thanks!  Where  would I have found this? (besides posting the
> question).
>
Author
4 Dec 2005 1:31 PM
cbDevelopment
The proper javascript event for drop down lists is onChange.

ddl_specs.attributes.add("onchange","return OnChangeSpec();")

----
700cb Development, Inc.
http://www.700cb.net
..NET utilities, developer tools,
and enterprise solutions

ezela***@hotmail.com wrote in news:1133463351.201242.34780
@g47g2000cwa.googlegroups.com:

Show quoteHide quote
> I am trying to get a client side javascript function to invoke when the
> selection changes in a drop down list box.  I have tried :
>
> ddl_specs.Attributes["language"] = "javascript";
> ddl_specs.Attributes["OnSelectedIndexChanged"] = "return
> OnChangeSpec();";
>
> with & without the "return"; and with & without AutoPostBack = true on
> the list box property and the javascript function just will not
> execute.
>
> I have gotten client side java script to work on an asp:button by
> adding the javascript function via the attributes collection, so I am
> not sure what else could be going on here.
>
> Much Thanks.
>
>



--