天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

Jquery+WebService 校驗賬號是否已被注冊的代碼

詳細代碼如下:
Default.ASPx
復制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.ASPx.cs" Inherits="Ajax_XML._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/Javascript" src="jquery-1.3.2-vsdoc2.js" language="Javascript"></script>
<script type="text/Javascript" language="Javascript">
$(function() {
$("#<%=UserID.ClientID%>").keyup(
function() {
$.ajax({
type: "POST",
contentType: "application/json",
dataType: "json",
url: "WebService1.asmx/UserIsExist",
data: "{UserID:'" + $("#<%=UserID.ClientID%>").val() + "'}",
success: function(result) {
if (result.d == "true")
$("#<%=IsExist.ClientID%>").text("Yes");  //賬號已存在
else
$("#<%=IsExist.ClientID%>").text("No");  
}
});
}
);
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width:100%;">
<tr>
<td>
 </td>
<td>
 </td>
<td>
 </td>
</tr>
<tr>
<td>
 </td>
<td>
<ASP:TextBox ID="UserID" runat="server"></ASP:TextBox>
<ASP:Label ID="IsExist" runat="server" Visible="true"></ASP:Label>
</td>
<td>
 </td>
</tr>
<tr>
<td>
 </td>
<td>
 </td>
<td>
 </td>
</tr>
</table>
</div>
</form>
</body>
</html>

WebService1.asmx.cs
復制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
using DAL;
namespace Ajax_XML
{
/// <summary>
/// WebService1 的摘要說明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允許使用 ASP.NET AJAX 從腳本中調用此 Web 服務,請取消對下行的注釋。
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello,World!";
}
[WebMethod]
public string UserIsExist(string UserID)
{
string sql = string.Format("select * from Customers where FirstName='" + UserID+"'");
using (SqlDataReader dr = SqlHelper.ExecuteSql(sql))
{
if (dr.Read())
return "false";
else
return "true";
}
}
}
}

SqlHelper.cs
復制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace DAL
{
/// <summary>
/// 數據庫操作類
/// </summary>
public class SqlHelper
{
private static SqlConnection conn;
private static SqlCommand comm;
private static SqlDataReader dr;
/// <summary>
/// 打開數據庫連接
/// </summary>
public static void ConnOpen()
{
try
{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BBS"].ConnectionString);
conn.Open();
}
catch (Exception e)
{
Console.WriteLine( e.Message);
}
}
/// <summary>
/// 關閉數據庫連接,釋放資源
/// </summary>
public static void ConnClose()
{
if (conn != null)
{
conn.Close();
}
if (comm != null)
{
comm.Dispose();
}
}
public static SqlDataReader ExecuteSql(string sql)
{
SqlHelper.ConnOpen();
comm = new SqlCommand(sql, conn);
try
{
dr = comm.ExecuteReader();
return dr;
}
catch (Exception e)
{
throw e;
}
}
}
}

JavaScript技術Jquery+WebService 校驗賬號是否已被注冊的代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 欧美互交人妖247 | 欧美区 bt | 成人午夜精品久久久久久久秋霞 | 持田香织abc| 天天综合亚洲综合网站 | 公粗挺进了我的密道在线播放贝壳 | 成人毛片18岁女人毛片免费看 | 女人精69xxxxx | 97人妻精品全国免费视频 | 国产成人在线视频免费观看 | 久久久精品日本一区二区三区 | 九九影院午夜理论片无码 | 我在厨房摸岳的乳HD在线观看 | 和搜子的日子 在线观看 | 成人国内精品久久久久影院 | a在线免费观看视频 | 欧美成人无码视频午夜福利 | 亚洲视频 在线观看 | 午夜福利理论片高清在线 | 又紧又大又爽精品一区二区 | 日韩精品一区二区中文 | 日韩欧无码一区二区三区免费不卡 | 欧美日韩亚洲第一区在线 | 11 13加污女qq看他下面 | 精品久久久久中文字幕加勒比东京热 | 九九九九九热 | 肉动漫h黄动漫日本免费观看 | 亚洲AV 中文字幕 国产 欧美 | 久久高清一本无码 | 亚洲午夜一区二区电影院 | 亚洲高清视频在线观看 | 一个人HD在线观看免费高清视频 | 国产精品内射久久久久欢欢 | 国产一在线精品一区在线观看 | 好男人在线观看视频观看高清视频免费 | 妈妈的朋友5在线观看免费完整版中文 | 成人免费视频网站www | 亚洲国产高清福利视频 | 欧美性猛交xxxxxxxx软件 | 99国产电影 | 亚洲 欧美 日韩 卡通 另类 |