2015-04-15 66 views
0

我需要將用戶輸入的html用戶名,電子郵件和密碼以html形式(在index.aspx中)輸入,並在另一個asp.net代碼中使用它(名爲'u'的文件夾中的register.aspx)。Request.QueryString不會從html表單獲取輸入名稱

這是形式:

<form action="u/register.aspx" method="post" id="regForm"> 
      <input type="text" name="fname" id="fname" placeholder="Full Name (Optional)" maxlength="16" /> 
      <input type="text" name="uname" id="uname" placeholder="Username" maxlength="16" /> 
      <input type="email" name="email" id="email" placeholder="Email Address" maxlength="32" /> 
      <input type="password" name="pwd" id="pwd" placeholder="Password" maxlength="16" /> 
      <input type="password" name="repwd" id="repwd" placeholder="Repeat Password" maxlength="16" /> 

      <input type="submit" value="Sign Up" id="signup" /> 
</form> 

但是,當我使用的Request.QueryString [「FNAME」]例如,它並不需要「FNAME」從形式上,它只是需要空值。

我能做些什麼來解決這個問題?有沒有不同的方法可以用來實現想要的結果?

非常感謝!

+1

'QueryString'會從查詢字符串足夠令人驚訝的信息。你已經發布了你的表單,你需要'request.Form' – paqogomez

回答

1

你做錯了。 Request.QueryString包含與之後添加的數據相關的信息?在URL中(例如http://www.contoso.com?mydata=1&param2=yy)。

您必須使用Request.Form來訪問「POST」數據。

+0

**非常感謝!**顯然,我的老師使用'get'方法(我用'post'),這就是他使用Request.QueryString的原因。它現在奇妙地工作。 – Theodore

1

QueryString只會給出url查詢字符串的參數here

如果你想要所有的參數,你將需要使用Params屬性。

0

正如其他人已經說過Request.QueryString包含數據之後?在URL中。

您可以使用Request.Form或者如果你想將數據作爲URL的一部分,你可以改變你的表單元素屬性的方法「獲得」