DropDown Validation Problem
-
I am working on asp.net 2.0 with c#, In my project there is a dropdown which having autopostback enabled. i have to validate its selection. i write javascript for it like that. <script type="text/javascript"> function alertOnBadSelection() { var select = document.getElementById('ddlContract').value; if (select=="-1") { alert('Please select contract'); return false; } else {return true;} } </script> this working fine as script when wrong selection,but when i select right selection dropdown's OnSelectedIndexChanged event not fire. can any one tell me how i will resolve my problem. thanks
-
I am working on asp.net 2.0 with c#, In my project there is a dropdown which having autopostback enabled. i have to validate its selection. i write javascript for it like that. <script type="text/javascript"> function alertOnBadSelection() { var select = document.getElementById('ddlContract').value; if (select=="-1") { alert('Please select contract'); return false; } else {return true;} } </script> this working fine as script when wrong selection,but when i select right selection dropdown's OnSelectedIndexChanged event not fire. can any one tell me how i will resolve my problem. thanks
-
How you are calling the JavaScript function at client side? It should be like 'return alertOnBadSelection();' Make sure that AutoPostback property is true.
*jayakrishnan
Thanks for replying me. i am calling alertOnBadSelection() this function on onchange="return alertOnBadSelection();"like that. if it is working fine for wrong selection, but when i make right selection it not postback page. dropdown OnSelectedIndexChanged event not fire. can u hepl me on it. thanks