Access User Name and Password from Sign In Control
Store information about the logged in user for subsequent use in your application. For example, maintain an "audit table" to track who logged in to the application and when.
- Pooja Daga, Technical Support Engineer, Iron Speed, Inc.

May 10, 2006
Iron Speed Designer V3.2

Introduction
Frequently it is useful to store information about the logged in user for subsequent use in your application. For example, you might maintain an "audit table" to track who logged in to the application and when. Such information is conveniently stored in session variables and can be useful while creating an audit trail.
Procedure
Follow these steps to access the UserName and Password of a signed-in user from within the Sign In control.

Step 1: In Iron Speed Designer, create an application using a database table, such as the Orders table in Northwind.

Step 2: Enable role-based security using the Role-Based Security Wizard in Iron Speed Designer.

Step 3: Select the Security tab in the Properties dialog for the ShowOrdersTablePage.aspx page. Select “Grant Access only to signed-in users”.

Step 4: Add the following code in the SignIn_Control class of SignIn_Control.ascx.cs or .vb, located in

...\<Application folder>\Shared\SignIn_Control.ascx.cs or .vb

C#:

public SignIn_Control()
{
    this.Init += new EventHandler(SignIn_Control_Init);
}
 
private void SignIn_Control_Init(object sender, System.EventArgs e)
{
    this.LoginSucceeded += new LoginSucceededHandler(SignIn_Control_LoginSucceeded);
}
 
private void SignIn_Control_LoginSucceeded(object sender,System.EventArgs e)
{
    string myUserName = this.UserName.Text;
    string myPassword = this.Password.Text;
}

Visual Basic .NET, .NET Framework 1.1:

Private Sub Page_LoginSucceeded(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.LoginSucceeded
    'Access UserName and Password
        Dim myUserName As String = Me.UserName.Text
        Dim myPassword As String = Me.Password.Text
End Sub

Visual Basic .NET, .NET Framework 2.0:

Protected Sub Page_LoginSucceeded1(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.LoginSucceeded
        Dim myUserName As String = Me.UserName.Text
        Dim myPassword As String = Me.Password.Text
End Sub

Step 5: Build and run your application.

About the Author
Pooja Daga
Technical Support Engineer, Iron Speed, Inc.

Pooja has experience developing Web applications using .NET technology. She started her career with PCS, a leading software services company headquartered in India and has been with Iron Speed since 2005.

Pooja holds an M.S. degree in Computer Application and a B.S. degree in Electrical engineering from Maharaja Sayajirao University in India.



  Privacy Statement