JS页面:
$.get("ashx/username.ashx",{username:$("#username").val()}, function(data){ 
        $("#txtOrderId23").val(data[0].Email);
    }, 
    "json");ashx页面
      string username = System.Web.HttpContext.Current.Request["username"].ToString();
        dt = userinfo.user.getUser(username);
        string msg = "[{";
        for (int i = 0; i < 1; i++)
        {
            msg += "username:\"" + dt.Rows[i]["username"].ToString();
            msg += "\",Email:\"" + dt.Rows[i]["Email"].ToString();
            msg += "\"";
        }
        msg += "}]";string username = System.Web.HttpContext.Current.Request["username"].ToString();这样接收参数是错误的,
要怎么接收传递过来的用户名??

解决方案 »

  1.   

    tring username= context.Request.Form["username"];
      

  2.   

    少打了个S,不好意思
    string username= context.Request.Form["username"];
      

  3.   

     string username = context.Request.QueryString["username"];  
      

  4.   

     我写的简单例子: 简单的jQuery检测注册用户名http://blog.csdn.net/gdjlc/archive/2009/11/20/4840261.aspx
      

  5.   


    /// <summary>
            /// 获取post string参数
            /// </summary>
            /// <param name="key"></param>
            /// <returns></returns>
            public static string GetPostString(string key)
            {
                var Request = HttpContext.Current.Request;
                string returnValue;
                try
                {
                    returnValue = Request[key];
                    returnValue = HttpUtility.UrlDecode(returnValue, Encoding.UTF8);
                }
                catch (Exception e)
                {
                    throw (e);
                }
                return string.IsNullOrEmpty(returnValue) ? null : returnValue;
            }