
復(fù)制代碼 代碼如下:
[System.Web.Services.WebMethod]
public static string VeryUserName(string name)
{
string rtn = "恭喜,此帳號還沒有注冊,你可以使用。";
if (name == "")
rtn = "請?zhí)顚懸粋€注冊帳號。";
if (name == "Insus.NET")
rtn = "此用戶已經(jīng)注冊,請使用另外帳號。";
return rtn;
}
復(fù)制代碼 代碼如下:
Account:
<asp:TextBox runat="server"></asp:TextBox><br />
<input type="button" value="注冊" />
復(fù)制代碼 代碼如下:
<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function VeryRegAccount() {
$.ajax({
type: "POST",
url: "Default.aspx/VeryUserName",
data: '{name: "' + $("#<%= TextBoxAccount.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
</script>

新聞熱點
疑難解答
圖片精選