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?
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?