120分,ajaxpro返回null值的问题,谢谢。
开发环境:vs2003,ajaxpro 2
ajax总是返回null值,麻烦大家看下。谢谢。
前台代码:
function regjs()
{
cq.reg.reguser(showcalendarcallback);
}
function showcalendarcallback(res)
{
alert(res.value); //这个地方返回一个null值。
}
后台代码://后台代码用非ajax可以成功执行
AjaxPro.Utility.RegisterTypeForAjax(typeof(reg));
[AjaxPro.AjaxMethod()]
public string reguser()
{
string returnvalue = "0 ";
string email = this.Request[ "emlInput "];
string petname = this.Request[ "usrInput "];
string password = this.Request[ "pwdInput "];
try
{
if(checkemail(email) == "0 " && checkpetname(petname) == "0 ")
{
int check = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings[ "checkuser "].ToString());
string sex = this.sexradio.SelectedValue.ToString();
string ip = myconfig.getip( "ip ").ToString();
DateTime dt = DateTime.Now;
string date = dt.ToString( "yyyy-MM-dd HH:mm:ss ");
SqlParameter[] sqp = new SqlParameter[7];
sqp[0] = new SqlParameter( "@email ",SqlDbType.VarChar);
sqp[0].Value = email;
sqp[1] = new SqlParameter( "@petname ",SqlDbType.VarChar);
sqp[1].Value = petname;
sqp[2] = new SqlParameter( "@password ",SqlDbType.VarChar);
sqp[2].Value = password;
sqp[3] = new SqlParameter( "@sex ",SqlDbType.VarChar);
sqp[3].Value = sex;
sqp[4] = new SqlParameter( "@ip ",SqlDbType.VarChar);
sqp[4].Value = ip;
sqp[5] = new SqlParameter( "@date ",SqlDbType.VarChar);
sqp[5].Value = date;
sqp[6] = new SqlParameter( "@check ",SqlDbType.Bit);
sqp[6].Value = check;
System.Data.SqlClient.SqlCommand mycmd = mydb.CreateCmd( "WF_reguser ",sqp);
mycmd.ExecuteNonQuery();
mycmd.Dispose();
mydb.ReturnConn().Close();
.ReturnConn().Dispose();
returnvalue = "1 ";
}
else
{
myconfig.errmsg( "对不起,您输入的邮箱地址或者个性昵称有误,请返回检查. ", "1 ");
}
}
catch
{
.errmsg( "对不起,您输入的资料有误,请返回检查. ", "1 ");
}
return returnvalue; //要在前台读取该值
}
----------------------------------
两个帖子,另一个帖子100分。
http://community.csdn.net/Expert/topic/5311/5311434.xml?temp=.188244
------解决方案--------------------string email = this.Request[ "emlInput "];
string petname = this.Request[ "usrInput "];
string password = this.Request[ "pwdInput "];
???
页面回发没?没回发取不到值。如果不回发的话通过js获取值。传到服务器端。
public string reguser(在这里加参)
前台reg.reguser( "传到服务端 ",showcalendarcallback);
function showcalendarcallback(res)
{
再看返回值
}
------解决方案--------------------Request 不能用在Ajax方法里,另外服务器控件之类的东西也不能在这里用