我在学习post 和get在网页中传值时,做了一个小例子,做了一个用户登录的
login.html在html代码中
<body>
<form action ="index.aspx" method="post">    用户名称:<input id="username" type="text" />
    <br />
    用户密码:<input id="userpwd" type="text" /><br />
    <br />
    &nbsp;<input id="Submit1" type="submit" value="提交" onclick="return Submit1_onclick()" />
    <input id="Reset2" type="reset" value="重置" /></form>
</body>把输入的用户名和密码传给index.aspx接收
                  string userName = Request.Form["username"].ToString();
                string userPwd = Request.Form.Get("userpwd").ToString();
                Response.Write("用户名称:" + userName + "用户密码:" + userPwd);
但使用中怎么总是取不到值,还提示未将对象引用设置到对象的实例。
这是怎么回事

解决方案 »

  1.   

    ASP.NET 呀 我用VS2005写的代码!
      

  2.   

    不能用id,要用name.
    用户名称: <input name ="username" type="text" /> 
        <br /> 
        用户密码: <input name ="userpwd" type="text" /> <br /> 
        <br /> 
      

  3.   


                      string userName = Request.Form["username"].ToString(); 
                    string userPwd = Request.Form.Get("userpwd").ToString(); 
                    Response.Redirect("index.aspx?用户名称="+userName &"用户密码="+userPwd);
      

  4.   

    用Request从input中取值要用到name
      

  5.   

    你用的是HTML控件,如果是服务器控件就太好办了,如果是HTML控件就NAME属性吧
      

  6.   

    可能是你设置的问题 

    http://www.xueit.com/html/2009-04/21_1013_00.html