ASP.NET WebForm 前端验证通过进入后端

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function one() {
            if (false) {
                return true;
            } else {
                return false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return one();" 
            onclick="Button1_Click" />
    </div>
    </form>
</body>
</html>
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write("This is Behind Code");
        }

asp.net控件的onClientClick return 执行js函数,true通过则进入后端方法,false则不通过。

posted @ 2016-06-07 11:19  chinchiu  阅读(529)  评论(0编辑  收藏  举报