一个判断用户名是否被注册的随笔

[AjaxPro.AjaxMethod]
        
public  DataSet show2( string  sn)
        
{
            
string sql="select * from sheng where shengname like '%"+sn+"%' ";
            
return sqlwz.foundcn(sql,"sheng");
        }

        [AjaxPro.AjaxMethod]
        
public   string  checkuser( string  sn)
        
{
            WebApplication1.DB user
=new WebApplication1.DB();
            Boolean valid;
            
string sql = "Select * from users where UserName = '" + sn + "'";
            SqlDataReader reader 
=user.ReaderSql(sql);
            
if(reader.Read())
            
{
                valid
=false;
            }

            
else
            
{
                valid
=true;
            }

            reader.Close();
            user.close();
            
return valid.ToString();
        }
<% @ Register TagPrefix="ajax" Namespace="MagicAjax.UI.Controls" Assembly="MagicAjax"  %>
<% @ Page language="c#" Codebehind="aa.aspx.cs" AutoEventWireup="false" Inherits="ty.aa"  %>
<% @ Register TagPrefix="uc1" TagName="top" Src="top.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="wzlist" Src="wzlist.ascx"  %>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"  >
< HTML >
    
< HEAD >
        
< title > aa </ title >
        
< meta  content ="Microsoft Visual Studio .NET 7.1"  name ="GENERATOR" >
        
< meta  content ="C#"  name ="CODE_LANGUAGE" >
        
< meta  content ="JavaScript"  name ="vs_defaultClientScript" >
        
< meta  content ="http://schemas.microsoft.com/intellisense/ie5"  name ="vs_targetSchema" >
        
< script  language ="javascript"  type ="text/javascript" >
         
function GetValue()
        
{
            
var shname=document.getElementById("input1").value;
            
var ds=ty.aa.show2(shname).value;
            
var lbl=document.getElementById("ss");
            
var temp="";
            temp
=temp+"<table width=300 heigth=300 border=1>";
            
for(var i=0;i<ds.Tables[0].Rows.length;i++)
            
{
                temp
=temp+"<tr>";
                temp
=temp+"<td>";
                temp
=temp+ds.Tables[0].Rows[i].shengName;
                temp
=temp+"</td>";
                temp
=temp+"<td>";
                temp
=temp+ds.Tables[0].Rows[i].MpNum;
                temp
=temp+"</td>";
                temp
=temp+"</tr>";
            }

            temp
=temp+"</table>";
            lbl.innerHTML
=temp;
        }

        
function check()
        
{
          
var username=document.getElementById("uname").value;
          
if(username=="")
          
{alert("null");return;}
          
var checked=ty.aa.checkuser(username).value;
          document.getElementById(
"result").style.display ='';
          
if(checked=="True")
          
{
            document.getElementById(
"result").innerHTML="恭喜您,可以注册!";
          }

          
else
          
{
            document.getElementById(
"result").innerHTML="此帐号已经被注册,请更换!";
            document.getElementById(
"uname").value="";
          }

        }

        
</ script >
    
</ HEAD >
    
< body  MS_POSITIONING ="GridLayout" >
        
< form  id ="Form1"  method ="post"  runat ="server" >
            
< TABLE  id ="Table1"  style ="Z-INDEX: 101; LEFT: 32px; WIDTH: 504px; POSITION: absolute; TOP: 88px; HEIGHT: 78px"
                cellSpacing
="1"  cellPadding ="1"  width ="504"  border ="1" >
                
< TR >
                    
< TD >< FONT  face ="宋体" ></ FONT ></ TD >
                    
< TD >< FONT  face ="宋体" ></ FONT ></ TD >
                    
< TD ></ TD >
                
</ TR >
                
< TR >
                    
< TD >< INPUT  id ="input1"  type ="text" >< INPUT  onclick ="GetValue()"  type ="button"  value ="加载" ></ TD >
                    
< TD >< INPUT  id ="uname"  type ="text"  onchange ="check()" >< div  id ="result"  onclick ="this.style.display ='none'"  style ="FONT-SIZE: 12px;Z-INDEX: 2007;CURSOR: hand;BACKGROUND-COLOR: #ffcc00" ></ div >
                    
</ TD >
                    
< TD >< FONT  face ="宋体" ></ FONT >< INPUT  onclick ="check()"  type ="button"  value ="检测" ></ TD >
                
</ TR >
                
< TR >
                    
< TD >< DIV  id ="ss"  ms_positioning ="FlowLayout" >< FONT  face ="宋体" ></ FONT ></ DIV >
                    
</ TD >
                    
< TD >< FONT  face ="宋体" >
                            
< asp:TextBox  id ="TextBox1"  runat ="server" ></ asp:TextBox ></ FONT ></ TD >
                    
< TD >< FONT  face ="宋体" >
                            
< asp:RequiredFieldValidator  id ="RequiredFieldValidator1"  runat ="server"  ErrorMessage ="RequiredFieldValidator"
                                ControlToValidate
="TextBox1" ></ asp:RequiredFieldValidator ></ FONT ></ TD >
                
</ TR >
            
</ TABLE >
            
&nbsp;&nbsp;&nbsp;
        
</ form >
    
</ body >
</ HTML >
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值