日期:2014-05-17  浏览次数:20555 次

CheckBox加JS验证后不触发服务端事件
JScript code

    <script type="text/javascript">

        function GoIndex(zno) {
            var mess = "";
            if (zno == 1) {
                mess = $("#txtSummary1").val();
            } else
                if (zno == 2) {
                    mess = $("#txtSummary2").val();
                } else
                    if (zno == 3) {
                        mess = $("#txtSummary3").val();
                    } else
                        if (zno == 4) {
                            mess = $("#txtSummary4").val();
                        } else
                            if (zno == 5) {
                                mess = $("#txtSummary5").val();
                            } else { }

            if (confirm("确定标记:" +mess+ " 吗?")) {
                return true;
            }
            else {
                return false;
            }

        } 


    </script>



HTML code


<asp:CheckBox ID="chbZY2" onclick="return  GoIndex(2);" runat="server" 
                                                Visible="true" AutoPostBack="True" oncheckedchanged="chbZY2_CheckedChanged" />



每次执行完JS 即使是True 也不执行服务端事件 oncheckedchanged="chbZY2_CheckedChanged" 这是怎么回事?回发也开启了

------解决方案--------------------
改成
onclick="return GoIndex(2);"

onclick="if(!GoIndex(2)){return false;}"