当前位置: 代码迷 >> ASP.NET >> CheckBox添JS验证后不触发服务端事件
  详细解决方案

CheckBox添JS验证后不触发服务端事件

热度:269   发布时间:2013-02-25 00:00:00.0
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;}"
  相关解决方案