自定义验证控件两层
来源:互联网 发布:淘宝网高音板胡 编辑:程序博客网 时间:2024/06/03 00:53
第一层;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
//string connstr = ConfigurationManager.AppSettings["zd"];
//SqlConnection con = new SqlConnection(connstr);
//con.Open();
//SqlCommand cmd=new SqlCommand("select count(*) from 学生表 where stuName='"+this.TextBox1.Text+"'",con);
//int name = Convert.ToInt32(cmd.ExecuteScalar());
string con = ConfigurationManager.AppSettings["zd"];
string sqlcmd="select count(*) from 学生表 where stuName='"+this.TextBox1.Text+"'";
int name = DAL.database.ReturnName(con, sqlcmd);
if (name > 0)
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
}
}
DAL层:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class database
{
public static int ReturnName(string constr, string sqlcmdsql)
{
SqlConnection cn = new SqlConnection(constr);
cn.Open();
SqlCommand cmd = new SqlCommand(sqlcmdsql,cn);
int name = Convert.ToInt32(cmd.ExecuteScalar());
return name;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
//string connstr = ConfigurationManager.AppSettings["zd"];
//SqlConnection con = new SqlConnection(connstr);
//con.Open();
//SqlCommand cmd=new SqlCommand("select count(*) from 学生表 where stuName='"+this.TextBox1.Text+"'",con);
//int name = Convert.ToInt32(cmd.ExecuteScalar());
string con = ConfigurationManager.AppSettings["zd"];
string sqlcmd="select count(*) from 学生表 where stuName='"+this.TextBox1.Text+"'";
int name = DAL.database.ReturnName(con, sqlcmd);
if (name > 0)
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
}
}
DAL层:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class database
{
public static int ReturnName(string constr, string sqlcmdsql)
{
SqlConnection cn = new SqlConnection(constr);
cn.Open();
SqlCommand cmd = new SqlCommand(sqlcmdsql,cn);
int name = Convert.ToInt32(cmd.ExecuteScalar());
return name;
}
}
}
- 自定义验证控件两层
- 自定义客户端验证控件
- 创建自定义验证控件
- 自定义“验证码”控件
- 自定义“验证码”控件
- 自定义验证控件类
- 自定义“验证码”控件
- CustomValidator自定义验证控件
- 自定义验证码控件
- 自定义客户端验证控件 CustomValidator
- 使用自定义验证控件(RegularExpressionValidator)
- ASP.NET自定义验证控件
- WPF自定义正则验证控件
- jquery easyUI 自定义验证控件
- jquery自定义控件验证篇
- 【自定义控件】练习:验证码
- 自定义控件实现验证码
- Webix 控件自定义验证条件
- ASP.NET SESSION丢失问题解决方案
- ASP.NET中常用的优化性能方法
- 站点地图
- 自定义事件虚拟按钮
- 80后常说的60句话
- 自定义验证控件两层
- 用Forms认证无法显示图片
- 月亮网摘(2009.1.8)
- 在AIX 5L上配置与管理路由
- 利用ASP.NET框架创建网站登陆
- Internet Explorer 安全区域注册表项说明
- SQL存储图片
- CHtmlView的通信机制
- javascript小技巧