我有两个页面,a.htm,b.aspx.在a.htm上有两textBox(txtuserName,txtUserPwd)和一button,现我想点提交button时,在b.aspx上结收userName和userPwd,
代码如下:
string UserName = Request["txtUserName"] != null ? Request["txtUserName"].ToString() : string.Empty;
string UserPwd = Request["txtUserPwd"] != null ? Request["txtUserPwd"].ToString() : string.Empty;Response.Write("用户名是:" + UserName + "<br>密码是:" + UserPwd);
为什么当我提交的时候,什么都得不到呢?也就是得不到userName和UserPwd的值.(用post方式提交)
(不管我在a.htm的textbox上有没有输入值,得到的都是nothing,另,是在vs2005中,我在2003中是可以做到的,为什么会这样子啊?刚用05不久)

解决方案 »

  1.   

    help啊,不管我用post还是get,都得不到值,在2003中还是好好的,为什么到05中就不行了呢
      

  2.   

    Request["txtUserName"]  - > Request.Forms["txtUserName"]
      

  3.   

    呆呆虫,我改了也不行啊.我还用Request.Form.get("txtUserName").toString()也得不到,另外,没有你说的Request.Forms
      

  4.   

    <form action="***.aspx" method="post">
    htm页面有没有action="***.aspx" method="post"这句
      

  5.   

    a.htm:
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Untitled Page</title>
    </head>
    <body>
    <form action="Default.aspx"  method="post">
        <table  border=0 cellpadding=0 cellspacing=0 style="left: 95px; width: 300px; position: relative; top: 38px; height: 155px">
            <tr>
               
                <td style="width: 175px" align="left">
                    用户名:</td>
                <td style="width: 381px">
                    <input id="txtUserName" type="text" /></td>
            </tr>
            <tr>
               
                <td style="width: 175px">
                    密&nbsp; 码:</td>
                <td style="width: 381px">
                    <input id="txtUserPwd" type="text" /></td>
            </tr>
            <tr >
                <td colspan="2" align="center" valign="top">
                    <input id="Submit1" type="submit" value="提交" /></td>
               
            </tr>
        </table>
    </form>
    </body>
    </html>b.aspx是:
     protected void Page_Load(object sender, EventArgs e)
        {        string UserName = Request.Form.Get("txtUserName") != null ? Request.Form["txtUserName"].ToString() : string.Empty;
            string UserPwd = Request["txtUserPwd"] != null ? Request["txtUserPwd"].ToString() : string.Empty;
          Response.Write("用户名是:" + UserName + "<br>密码是:" + UserPwd);
    }
      

  6.   

    上面的就是改了也有错啊.我换成vs2003是可以通过的,为什么05就不行了.本来想用03开发的,但是03现在一切换到html模式就出错关闭了,找了n久都没决解,只好手写code,但太烦了.现在2问题一起问,有没有知道的朋友,help一下,多谢
      

  7.   

    <input id="txtUserName" type="text" />  =>  <input id="txtUserName" name="txtUserName" type="text" /><input id="txtUserPwd" type="text" />   =>   <input id="txtUserPwd" name="txtUserPwd" type="text" />