how to show dialog in login form?

rajesh.forum

Well-known member
Joined
Sep 7, 2007
Messages
55
Programming Experience
Beginner
i need to close the login form and to navigate another form when userid and password gets matched..
 
Set the main form as startup form. In Application Startup event you show the login form as dialog and use e.Cancel to stop application from starting if login fails. There's a code example in post 4 of this thread: http://www.vbdotnetforums.com/showthread.php?t=19637
 
but i need to know how and where to set dialogresult=OK?

hi john
i ve used application events as u said..
but i reall don no to use show dialog..

here is my code..plz take a view

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

lblMsg.Text = ""
Try
If Me.tbUName.Text <> " " AndAlso Me.tbPassword.Text <> " " Then
Dim dsLogin As New DataSet()
'Assigning the Login Result to Dataset
dsLogin = objUserMgmt.RetreiveLogin(tbUName.Text.Trim(), tbPassword.Text.Trim())
If dsLogin.Tables.Count > 0 Then
If dsLogin.Tables(0).Rows.Count > 0 Then
'show welcome page
strLoginName = dsLogin.Tables(0).Rows(0)("loginname").ToString()
strPassword = dsLogin.Tables(0).Rows(0)("password").ToString()
strMenuId = dsLogin.Tables(0).Rows(0)("menuid").ToString()
struserName = dsLogin.Tables(0).Rows(0)("name").ToString()
MsgBox("Parikshaa Welcomes " & struserName, MsgBoxStyle.Information, "Parikshaa")

'this is the form i shud navigate
'------------------------------
FrmBoardUniversity.Show()
Else
lblMsg.ForeColor = Color.Red
lblMsg.Text = "UserName and Password Do Not Match"

End If
End If
Else
lblMsg.ForeColor = Color.Red
lblMsg.Text = "UserName and Password Cannot be Empty"
tbUName.Focus()
End If
Catch ex As Exception
MsgBox(ex.InnerException)
Finally
tbUName.Text = ""
tbPassword.Text = ""
End Try
Me.Close()
End Sub
 
When you are finished with the login stuff set Me.DialogResult=OK if ok or another value if not ok.
 
John

Is that how you would handle the login if you were using the standard windows login form, or could you use the same code if you are creating your own login form?

I ask because I have a standard login form and class that I use for all my small apps that are password protected.

Thanks
CoachBarker
 
Yes, the LoginForm template is designed as a dialog, you just has to set DialogResult as appropriate to the authentication.
 
Back
Top