<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQL" %> ASP+注册
论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > asp教程
Tag:入门,文摘,实例,技巧,iis,表单,对象,上传,数据库,记录集,session,cookies,存储过程,注入,分页,安全,优化,xmlhttp,fso,jmail,application,防盗链,stream,组件,md5,乱码,缓存,加密,验证码,算法,ubb,正则表达式,水印,,日志,压缩,url重写,控件,函数,破解,触发器,socket,ADO,初学,聊天室,留言本,视频教程

简易ASP+注册系统

文章类别:asp | 发表日期:2008-10-5 20:55:02

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<html>
<head><title>ASP+注册</title>
<link rel="stylesheet" type="text/css" href="main.css">
<Script Language="C#" RunAt=Server>
void btnSubmit_Click(Object Src,EventArgs E)
{
     if(Page.IsValid)
     {
    String strSQL;
    strSQL="INSERT INTO tblUserInfo VALUES(@UserName,@PassWord,@Email)";
    
    SQLConnection cnn=new SQLConnection("Server=niu;UID=sa;PWD=;DataBase=aspx");
    SQLCommand cmm=new SQLCommand(strSQL,cnn);
    
    cmm.Parameters.Add(new SQLParameter("@UserName",SQLDataType.VarChar,20));
    cmm.Parameters["@UserName"].Value=txtName.Text;
    
    cmm.Parameters.Add(new SQLParameter("@PassWord",SQLDataType.VarChar,20));
    cmm.Parameters["@PassWord"].Value=txtName.Text;
    
    cmm.Parameters.Add(new SQLParameter("@Email",SQLDataType.VarChar,60));
    cmm.Parameters["@Email"].Value=txtName.Text;

    cmm.ActiveConnection.Open();
    try
    {
      cmm.Execute();
      cmm.ActiveConnection.Close();
      Page.Navigate("result.aspx");
    }
    catch
    {
      lblMsg.Style["color"]="red";
      lblMsg.Text="插入数据出错";
    }
     }

}
</Script>
</head>
<body>
<h2 align="center">ASP+注册系统</h2>
<ASP:Label ID="lblMsg" RunAt=Server/>
<form RunAt=Server>
  <table bgcolor="#eeeeee" cellpadding="10" align="center">
   <tr>
      <td>姓名:</td>
      <td>
        <ASP:TextBox ID="txtName" MaxLength="20" Class="mytext" RunAt=Server/>
      </td>
      <td>
        <ASP:RequiredFieldValidator ID="rfvName"
             ControlToValidate="txtName"
         Display="Dynamic"
         InitalValue=""
         ErrorMessage="*"
         RunAt=Server>
        </ASP:RequiredFieldValidator>
      </td>
    </tr>
    <tr>
      <td>密码:</td>
      <td>
    <ASP:TextBox ID="txtPassWord" TextMode="PassWord" MaxLength="20" Class="mytext" RunAt=Server/>
      </td>
      <td>
    <ASP:RequiredFieldValidator ID="rfvPassWord"
         ControlToValidate="txtPassWord"
         Display="Dynamic"
         InitialValue=""
         ErrorMessage="*"
         RunAt=Server>
    </ASP:RequiredFieldValidator>
      </td>
    </tr>
    <tr>
      <td>确认密码:</td>
      <td>
        <ASP:TextBox ID="txtRePassWord" TextMode="PassWord" MaxLength="20" Class="mytext" RunAt=Server/>
      </td>
      <td>
        <ASP:RequiredFieldValidator ID="rfvRePassWord"
         ControlToValidate="txtRePassWord"
         Display="Dynamic"
         InitialValue=""
         ErrorMessage="*"
         RunAt=Server>
    </ASP:RequiredFieldValidator>
    <ASP:CompareValidator ID="cvRePassWord"
         ControlToValidate="txtRePassWord" ControlToCompare="txtPassWord"
         Display="Dynamic"
         ErrorMessage="密码确认错,请注意字母大小写!"
         Runat=Server>
    </ASP:CompareValidator>
      </td>
    </tr>
    <tr>
      <td>电子邮件:</td>
      <td>
        <ASP:TextBox ID="txtEmail" MaxLength="60" Class="mytext" RunAt=Server/>
      </td>
      <td>
        <ASP:RequiredFieldValidator ID="rvfEmail"
         ControlToValidate="txtEmail"
         InitialValue=""
         Display="Dynamic"
         ErrorMessage="*"
         RunAt=Server>
    </ASP:RequiredFieldValidator>
    <ASP:RegularExpressionValidator ID="revEmail"
             ControlToValidate="txtEmail"
             Display="Dynamic"
             ErrorMessage="无效电子邮件地址!"
         ValidationExpression="^[\w-]+@[\w-]+\.(com|net|org|edu|mil)$"
             RunAt=Server>
        </ASP:RegularExpressionValidator>
      </td>
    </tr>
    <tr>
      <td colspan="3" align="center">
        <ASP:Button ID="btnSubmit" OnClick="btnSubmit_Click" Text="提交" Class="mybtn" RunAt=Server/>      
      </td>
   </tr>
  </table>
</form>
</body>
</html>

视频教程列表
文章教程搜索
 
Asp推荐教程
Asp热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058