无刷新验证问题
问题:每次输入一个姓名的时候,必须重新启动一下程序,要不就验证不出来这个最新输入的姓名
aspx页面代码:
<script language="javascript" type="text/javascript">
<!--
var E_name,I_name
function ChenckName()
{
E_name = document.getElementById("txt_E_name").value;
if(E_name == null || E_name == "")
{
form1.txt_E_name.focus();
Spen_name.innerHTML = "<font color=red>商城不能为空</font>";
return 0;
}
else
{
Spen_name.innerHTML = "<font color=green>查询中......</spen>";
myurl="Emporium_Select.ashx?name="+escape(E_name);
getCode = openUrl(myurl)
if(getCode != 0)
{
form1.txt_E_name.focus();
Spen_name.innerHTML="<font color=red> 商城名称不能重复</font>";
return 0;
}
else
{
Spen_name.innerHTML = "<font color=green>√</spen>";
}
}
}
function Chenck()
{
if(ChenckName()==0)
{
return false;
}
}
function openUrl(url)
{
var objxml=new ActiveXObject("Microsoft.XMLHttp")
objxml.open("GET",url,false);
objxml.send();
retInfo=objxml.responseText;
if (objxml.status=="200")
{
return retInfo;
}
else
{
return "-2";
}
}
-->
</script>
ashx代码:
<%@ WebHandler Language="C#" Class="Emporium_Select" %>
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using ShopManagement.BLL;
public class Emporium_Select : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/plain";
string name = context.Request.QueryString["name"].ToString();
context.Response.Write(Emporium.GetEmporiumName(name));
}
public bool IsReusable {
get {
return false;
}
}
}
------解决方案--------------------帮你顶!
最怕写页面端的函数验证,我一般都写在.cs文件里,用.net自带的验证控件,既然给你就拿来用,要不然放那好看?
------解决方案--------------------最简单的用AJAX了啊
------解决方案--------------------草率的问一下, 是不是必须用ajax才能无刷新?
有没有其他的方法可以实现?
------解决方案--------------------