Link to home
Start Free TrialLog in
Avatar of rawilken
rawilkenFlag for United States of America

asked on

asp.net VB login

I have a form with a drop down displaying all the potential users that can log into my application. I also have a text box where the user will enter the password. I have made the password field from the SQL Connection on the dropdown list the DataValueKey. I want to validate that the password entered matches the password value stored for that users record and if it is go to a different web page. If it does not, display an error message.

This is the html I have so far...
<asp:DropDownList ID="UserName" runat="server"
                                                      DataSourceID="InterspanDataSource1" DataTextField="Name"
                                                      DataValueField="Password">
                                    </asp:DropDownList>
                                    <asp:SqlDataSource ID="InterspanDataSource1" runat="server"
                                                       ConnectionString="<%$ ConnectionStrings:InterspanResourcesConnectionString %>"
                                                       SelectCommand="SELECT DISTINCT [OperatorID], [Name], [Password], [SecurityLevel] F                                        FROM [qry_UserLogin]">
                                    </asp:SqlDataSource>
                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
                                                                ControlToValidate="UserName" ErrorMessage="User Name is required."
                                                                ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                   
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password: </asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="Password" runat="server" TextMode="Password"
                                                 ontextchanged="PasswordText_Changed"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
                                                                ControlToValidate="Password" ErrorMessage="Password is required."
                                                                ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                                </td>


This is the vb codebehind I have so far. This where I am struggling.

Protected Sub LoginButtonClick(sender As Object, e As EventArgs)
        If Login1.Password = Login1.UserName Then

        Else
            Login1.FailureText = Visible
        End If
    End Sub
Avatar of plusone3055
plusone3055
Flag of United States of America image

Protected Sub LoginButtonClick(sender As Object, e As EventArgs)
        If Login1.Password = Login1.UserName Then
           Response.Redirect("http://www.microsoft.com")
        Else
            Login1.FailureText = Visible
        End If
    End Sub
SOLUTION
Avatar of plusone3055
plusone3055
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial