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


E

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.
 
Ad

Advertisements

G

Guest

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);
 
G

Guest

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/d...hop/author/dhtml/reference/objects/select.asp
 
Ad

Advertisements

C

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

(e-mail address removed) wrote in @g47g2000cwa.googlegroups.com:
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.



--
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top