Nightwolf
Nightwolf

Reputation: 951

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).

The current project used webforms and onclick triggers to get form values. It never posts any html form data.

Here is a base example to show what I need to know:

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

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?

Upvotes: 1

Views: 13837

Answers (1)

Allan S. Hansen
Allan S. Hansen

Reputation: 4081

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.
Check here for more information: http://www.w3schools.com/asp/coll_form.asp

Upvotes: 3

Related Questions