一个很简单的判断验证码方法,如果输入正确,返回1,否则返回0在本地win2003,framework2.0,IE6 测试完全没有问题,同样的程序上传到其他的虚拟主机也一切正常,但目前用的这个主机上就没有任何反应,他们也是支持.net framework2.0 ,其他程序运行也都正常,就这个不工作,奇怪可以确定是空间商那边设置的问题,但究竟可能是什么原因?哪里需要调整呢?跟他们协商也得能说到关键地方<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %><!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">
function changepic() {
document.getElementById("checkCodeImage").src="login/checkCode.aspx?n=" + Math.random();
document.getElementById("checkCode").value = '';
}
//发送到后台
function CallServer() {
var code = document.getElementById("checkCode").value;
<%= ClientScript.GetCallbackEventReference(this, "code", "ReceiveServerData",null)%>;
} //返回结果
function ReceiveServerData(rValue) {
alert(rValue);
}
</script></head>
<body>
<form id="form1" runat="server">
<div> <input type="text" runat="server" id="checkCode" onblur="CallServer()" />
<img id="checkCodeImage" src="login/checkCode.aspx" onclick="changepic()" alt="点击更新验证码" />
</div>
</form>
</body>
</html>--------------------------------------cs文件
public partial class test : System.Web.UI.Page, ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{ } private string CallBackValue; //得到发送来的值
string ICallbackEventHandler.GetCallbackResult()
{
string sessionValue;
try
{
sessionValue = Session["checkCode"].ToString(); if (sessionValue.ToString() == CallBackValue.ToString().ToUpper())
{ CallBackValue = "1"; }
else
{ CallBackValue = "0"; }
}
catch
{
Response.Write("<script>alert('超时!验证码已失效,请重新输入');changepic();</script>");
CallBackValue = "0"; } return CallBackValue;
} //返回结果
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
this.CallBackValue = eventArgument;
}}
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>测试</title>
<script type="text/javascript">
function changepic() {
document.getElementById("checkCodeImage").src="login/checkCode.aspx?n=" + Math.random();
document.getElementById("checkCode").value = '';
}
//发送到后台
function CallServer() {
var code = document.getElementById("checkCode").value;
<%= ClientScript.GetCallbackEventReference(this, "code", "ReceiveServerData",null)%>;
} //返回结果
function ReceiveServerData(rValue) {
alert(rValue);
}
</script></head>
<body>
<form id="form1" runat="server">
<div> <input type="text" runat="server" id="checkCode" onblur="CallServer()" />
<img id="checkCodeImage" src="login/checkCode.aspx" onclick="changepic()" alt="点击更新验证码" />
</div>
</form>
</body>
</html>--------------------------------------cs文件
public partial class test : System.Web.UI.Page, ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{ } private string CallBackValue; //得到发送来的值
string ICallbackEventHandler.GetCallbackResult()
{
string sessionValue;
try
{
sessionValue = Session["checkCode"].ToString(); if (sessionValue.ToString() == CallBackValue.ToString().ToUpper())
{ CallBackValue = "1"; }
else
{ CallBackValue = "0"; }
}
catch
{
Response.Write("<script>alert('超时!验证码已失效,请重新输入');changepic();</script>");
CallBackValue = "0"; } return CallBackValue;
} //返回结果
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
this.CallBackValue = eventArgument;
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货