Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Need syntax for Request.Form("whatever") in ASP to ASPX upgrade

  Asked By: Viveka    Date: Dec 07    Category: Asp.net    Views: 1638
  

Nothing is coming back(no errors), don't have a clue,
not sure how to get the Username and Password when the
"Login" button is clicked and the page calls itself.
This code worked in ASP and I pasted it into the code
behind and tweaked it a little. But it doesn't work.
It jumps the part where it sets the Session objects
because I'm not referencing the Form input right:


Imports System.Data
Imports System.Data.OleDb
Imports System.Configuration.ConfigurationSettings


Public Class login
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here
Dim vLoginName As String
Dim vPassword As String
Dim vThisAdminID As Integer
vLoginName = Request.Form("LoginName") & ""

If (Len(vLoginName) > 0) And
(Len(Request.Form("Password")) > 0) Then
*********skips out of the If clause and just reloads
the Login page

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Tammy Sanders     Answered On: Dec 07

I'm new on this hread but I can tell you taht theframework will prefix the name
of your control with an id it geneartes - usually ctl + a number.

So request.Form("LoginName") won't work  .... it has to be
Request.Form("ctl5_LoginName");

You can get a collection of form  members and loop through them ... thats in ms
help ....

In VB ...


Dim loop1 As Integer
Dim arr1() As String
Dim coll As NameValueCollection

' Load Form variables into NameValueCollection variable.
coll=Request.Form

' Get names of all forms into a string array.
arr1 = coll.AllKeys
For loop1 = 0 To arr1.GetUpperBound(0)
Response.Write("Form: " & arr1(loop1) & "<br>")
Next loop1


Then add a line to see the values Response.Write("Values are": " &
Request.Form(arr1(loop1)) & "<br>")

VB not  my systax so that may ot compile.

 




Tagged: