views:

77

answers:

2

I tried it but I am getting this error:

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30201: Expression expected.

Source Error:

Line 26:      password.Text = parseQuery("pass")
Line 27:     End If
Line 28:     If password.Text <> "" And username.Text <> "" Then btnLogin_Click(Dim sender as Object, Dim e as System.EventArgs)
Line 29:    End If
Line 30:    


Source File: C:\Inetpub\wwwroot\devv\login.aspx.vb    Line: 28
+3  A: 

Try changing your statement to read

If password.Text <> "" And username.Text <> "" Then 
   btnLogin_Click(Nothing, Nothing)
End If

Your current code is using the signature as if you were creating the button click event, you simply need to pass it some dummy arguments into the method, provided it has been written.

However, if you are triggering a login through various methods, I'd recommend writing a second method called ProcessLogin or something to that matter and have your button click event simply redirect to there. This will make it easier to have multiple "entry vectors" to your login processing.

Dillie-O
That's what I thought it should be, but I wasn't confident enough in VB knowledge. +1 for recommending a separate ProcessLogin method.
Joel Potter
A: 

You need to change line 28 from

If password.Text <> "" And username.Text <> "" Then btnLogin_Click(Dim sender as Object, Dim e as System.EventArgs)

to

If password.Text <> "" And username.Text <> "" Then btnLogin_Click(Nothing, EventArgs.Empty)
drs9222