[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();
}
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();
}
<% ... @ 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 >
</ form >
</ body >
</ HTML >