欢迎访问我的博客 https://javascript.shop

net5:自定义验证控件服务器端验证与客户端验证的使用

原文发布时间为:2008-07-29 —— 来源于本人的百度文章 [由搬家工具导入]

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            Label1.Text = "pass";
        }
        else
        {
            Label1.Text = "fail";
        }

    }
    protected void txtvlue(object source, ServerValidateEventArgs args)
    {
        if (args.Value == "服务端")
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }
   }

--------------------------------------

<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript">
    function txtvalue(s,e)
    {
       if(e.Value=="客户端")
       {
      
       e.IsValid=true;
       }
       else
       {
       e.IsValid=false;
       }
       }
    </script>
</head>
<body>

posted @ 2017-07-09 15:04  孑孓子  阅读(170)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop