Javascript + Asp.net = not firing event

D

Duwayne

I have a simple drop down list and I want the indexchange event to
fire when the user changes the index to 0. So, in other words, I want
the form to sumbit only when I change to index = 0, otherwise, it dont
submit.

At first, I turned on autopostback, and asp.net adds the
onchange="__doPostBack('id', '') to my drop down list on the client
side. This basically just submits everytime I changes the index. With
this code, it event always when I submit.

Then I turned off autopostback, and added attributes to my drop down
list. The attribute added is onchange, value is
"if(this.selectedIndex==0){__doPostBack('id','')}". So, when the page
is rendered, I get onchange="if(this.selectedIndex==0){__doPostBack('id','')}"
in my drop down list. This looks right. So I go about changing the
index. When I change the index to 0, the form submits, BUT the event
does not fire.

I then changed the attribute to just "__doPostBack('id','')" and with
this attribute, the form submits and the event is fired.

Now, the question is, why doesn't the first attribute work?
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top