hi,
i use the asp.net login control to add into a form.
i also use the asp.net database in the SQL back end.
everything done correctly until the point that i want to use the login page to login and redirect to my welcome page, but then it's doesn't go any where after i enter the correct username and password.
so please help to look at my code, and any suggestion will help a lot.
thank you.
Imports System.Data.SqlClient
Imports System.Data
Imports System.Globalization
Imports System.Web
Imports System.DirectoryServices
Imports System.Web.Security
Imports System.Configuration
Partial Class Login
Inherits System.Web.UI.Page
Protected Sub LoginButton_Click(sender As Object, e As EventArgs)
Dim connString As String = ConfigurationManager.ConnectionStrings("DBHUSRConnectionString").ConnectionString
Dim DBConnection As SqlConnection = New SqlConnection(connString)
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
DBConnection.Open()
DBCommand = New SqlCommand("QGlobalUserRecordsLogin_sp", DBConnection)
DBCommand.Parameters.AddWithValue("@UserID", Login1.UserName())
DBCommand.CommandType = CommandType.StoredProcedure
DBReader = DBCommand.ExecuteReader()
If DBReader.Read() Then
If Login1.UserName = DBReader("UserName") Then
Response.Redirect("~/Welcome.aspx")
End If
End If
DBConnection.Close()
End Sub
End Class
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center" colspan="2">Log In</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<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 align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="Login1" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
please let me know if you need any additional question.