求教一下 CustomValidator

[复制链接]
查看11 | 回复1 | 2010-12-3 05:58:47 | 显示全部楼层 |阅读模式
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 _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)

{

if (TextBox1.Text== "aaaaa")

{

args.IsValid = true;

}

else

{

args.IsValid = false;

}

}

protected voidButton1_Click(object sender, EventArgs e)
{

Response.Write("");
}
}
为什么乱填不填 都可以提交跳转呢
那两个控件都是直接拉的 求教高手..

回复

使用道具 举报

千问 | 2010-12-3 05:58:47 | 显示全部楼层
在Button1_Click里加个判断if(this.IsValid){
Response.Write("");}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行