rawilken
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="InterspanDat aSource1" DataTextField="Name"
DataValueField="Password">
</asp:DropDownList>
<asp:SqlDataSource ID="InterspanDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Interspa nResources Connection String %>"
SelectCommand="SELECT DISTINCT [OperatorID], [Name], [Password], [SecurityLevel] F FROM [qry_UserLogin]">
</asp:SqlDataSource>
<asp:RequiredFieldValidato r ID="UserNameRequired" runat="server"
ControlToValidate="UserNam e" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="Login1">* </asp:Requ iredFieldV alidator>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Passw ord">Passw ord: </asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"
ontextchanged="PasswordTex t_Changed" ></asp:Tex tBox>
<asp:RequiredFieldValidato r ID="PasswordRequired" runat="server"
ControlToValidate="Passwor d" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="Login1">* </asp:Requ iredFieldV alidator>
</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
This is the html I have so far...
<asp:DropDownList ID="UserName" runat="server"
DataSourceID="InterspanDat
DataValueField="Password">
</asp:DropDownList>
<asp:SqlDataSource ID="InterspanDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Interspa
SelectCommand="SELECT DISTINCT [OperatorID], [Name], [Password], [SecurityLevel] F FROM [qry_UserLogin]">
</asp:SqlDataSource>
<asp:RequiredFieldValidato
ControlToValidate="UserNam
ToolTip="User Name is required." ValidationGroup="Login1">*
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Passw
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"
ontextchanged="PasswordTex
<asp:RequiredFieldValidato
ControlToValidate="Passwor
ToolTip="Password is required." ValidationGroup="Login1">*
</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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If Login1.Password = Login1.UserName Then
Response.Redirect("http://www.microsoft.com")
Else
Login1.FailureText = Visible
End If
End Sub