简体   繁体   English

如何在VB.NET中使用发布和获取值?

[英]How to use post and get values in VB.NET?

I recently took over a web based project that is written vb.net (written by someone that did not know vb.net before he started). 我最近接手了一个基于Web的项目,该项目名为vb.net(由在他开始之前不了解vb.net的人编写)。

The current project used webforms and onclick triggers to get form values. 当前项目使用了webforms和onclick触发器来获取表单值。 It never posts any html form data. 它从不发布任何html表单数据。

Here is a base example to show what I need to know: 这是一个基本示例,显示我需要了解的内容:

login.aspx login.aspx的

<form name="LoginForm" action="auth.aspx?ref=LoginForm" method="post">
  <input type="text" name="username" />
  <input type="password" name="passphrase" />
  <input type="submit" value="Login">
</form>

auth.aspx.vb auth.aspx.vb

Dim ref as String = ???
Dim username As String = ???
Dim passphrase As String = ???

Dim strSQL As String = "SELECT usrId FROM Users WHERE UserName =@ParamName AND Password =@ParamPass"

dbCommand = New SqlCommand(strSQL, dbConn)
dbCommand.Parameters.AddWithValue("@UserName", username)
dbCommand.Parameters.AddWithValue("@ParamPass", passphrase)
dr = dbCommand.ExecuteReader

How assign these post and get values to these variables? 如何分配这些职位,并获得这些变量的值?

For your problem I would think this would work: 对于您的问题,我认为这会起作用:

Dim ref as String = Request.Querystring("ref") 
Dim username As String =Request.Form("username")
Dim passphrase As String = =Request.Form("passphrase")

As mentioned in my comment, if not using the asp.net webform functionality, you'll have to rely on the (basically) ASP version of functionality. 如我的评论中所述,如果不使用asp.net Webform功能,则必须依赖(基本上)ASP版本的功能。
Check here for more information: http://www.w3schools.com/asp/coll_form.asp 在此处查看更多信息: http : //www.w3schools.com/asp/coll_form.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM