日期:2014-05-16 浏览次数:20834 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="regest.aspx.cs" Inherits="regest" %> <!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 language="javascript" type="text/javascript"> function checkName() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } var name = document.getElementById("userName").value; if (name == null) { alert("用户名为空"); return; } var url = "Default.aspx?name="+escape(name); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { document.getElementById('span1').innerHTML = xmlhttp.responseText; alert("用户名为空!"); } } xmlhttp.open("POST", url, true); xmlhttp.send(null); } </script> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td align="center">新用户注册</td> </tr> <tr> <td> <input type="text" name="username" id="username" onchange="checkName()"; /> </td> <td> <span id="span1"></span> </td> </tr> </table> </div> </form> </body> </html>
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string name = Request["name"]; if (name == "sss") { Response.Write("测试成功"); } } }