Hello my dear ..
I have question about how to select one row from database where login is correct !
Example :
I have a table for members with all their information ..
I want the user to access his page via e-mail and password just ..
If the e-mail matches, it will be on its own page and so on ..
When he leaves the page returns to the Login page and does not remain on the same page Logout !
The code did not work for me and I do not know what is wrong here.
aspx page :
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="MemberLogin.ascx.vb" Inherits="AdminCTRL_MemberLogin" %>
<style type="text/css">
.style1
{
background-color: #666666;
}
</style>
<div style="height: 60px; width: auto; float: right; color: #800000; vertical-align: middle; padding-top: 10px;">
<asp:Label ID="LabelNameMember" runat="server" style="color: #FFFFFF"></asp:Label>
<asp:LinkButton ID="LinkButtonLogout" runat="server" Width="70px"
Visible="False" Font-Underline="False">Logout</asp:LinkButton>
<asp:TextBox ID="txtid" runat="server" CssClass="style1"
Height="19px" Visible="False" Width="91px"></asp:TextBox>
<asp:TextBox ID="txtpassword" runat="server" TextMode="Password"
CssClass="style1" height="19px" Visible="False" width="91px"></asp:TextBox>
<asp:LinkButton ID="LinkButtonLogin" runat="server" Width="70px"
Visible="False">Go</asp:LinkButton>
<asp:LinkButton ID="LoginShow" runat="server" Width="70px">Login</asp:LinkButton>
<asp:LinkButton ID="LinkButtonRegister" runat="server" Width="75px">Register</asp:LinkButton>
<br />
<asp:Label ID="lblMsg" runat="server" style="display:inline-block; height:47px; width:200px; padding:0px 30px 0px 105px; font-size : small; font-family: Tahoma; color: #800000;" ></asp:Label>
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Repeater ID="RepeaterMember" runat="server">
<ItemTemplate>
<div id="visibrep" style="height: 290px;width: 205px;float: left;text-align: left;direction: ltr;margin: 2px 10px 20px 10px;border: solid 1px #D5CBCB;padding: 10px 0px 10px 15px;border-radius: 20px;">
<div style="Margin-right:10px;text-align: left; direction: ltr;color: #0C19FF;height :155px;padding-left: 20px;"><img src="../../Style/images/pct/<%# Eval("MemberImage")%>.png"/></div>
<div style=" text-align: left; direction: ltr;color: #000;font-size: 13px;font-family: tahoma;margin-top: 7px;"><%# Eval("EnglishName")%></div>
<div style=" text-align: left; direction: ltr;color: #0C19FF;font-size: 13px;font-family: tahoma;"><%# Eval("CityName")%>, <%# Eval("CountryName")%></div>
<asp:Label ID="lblPCTLEVEL" runat="server" style=" text-align: left; direction: ltr;color: black;font-size: 13px;font-family: tahoma;float:left ;display: -webkit-box;"><%# Eval("PCTNote")%><%# ProcessMyDataItem(Eval("PCTName"))%></asp:Label>
<asp:Label ID="lblISIDLEVEL" runat="server" style=" text-align: left; direction: ltr;color: black;font-size: 13px;font-family: tahoma;float:left ;display: -webkit-box;"><%# Eval("ISIDNote")%><%# ProcessMyDataItem2(Eval("ISIDName"))%></asp:Label>
<asp:Label ID="lblSBSLEVEL" runat="server" style=" text-align: left; direction: ltr;color: black;font-size: 13px;font-family: tahoma;float:left ;display: -webkit-box;"><%# Eval("SBSNote")%><%# ProcessMyDataItem3(Eval("SBName"))%></asp:Label>
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
VB Code
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.DataSet
Imports System
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.OleDb
Partial Class httpdocs_AdminCTRL_MemberLogin
Inherits System.Web.UI.UserControl
Protected Sub LinkButtonLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonLogin.Click
Dim objM As New DB_Member
objM.ProEmail = txtid.Text
objM.ProPassword = txtpassword.Text
Dim dt As DataTable = objM.FindPass()
If dt.Rows.Count <> 0 Then
LinkButtonLogin.Visible = False
LinkButtonLogout.Visible = True
LinkButtonRegister.Visible = False
Dim objM3 As New DB_Member
objM3.ProEmail = txtid.Text
Dim reader As SqlDataReader = objM3.FindMember()
LabelNameMember.Visible = True
LabelNameMember.Text = "Welcome Mr/Ms." + objM3.ProEnglishName
txtid.Visible = False
txtpassword.Visible = False
Dim objC As String = "Email"
Dim foundRow As DataRow = DataSet1.Tables("Member").Rows.Find(objC)
If foundRow IsNot Nothing Then
MsgBox(foundRow(1).ToString())
Else
MsgBox("A row with the primary key of " & objC & " could not be found")
End If
Else
lblMsg.Text = "Plz Check U Email and Password"
End If
End Sub
Protected Sub LinkButtonLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonLogout.Click
LinkButtonLogin.Visible = True
LinkButtonLogout.Visible = False
LabelNameMember.Visible = False
LinkButtonRegister.Visible = False
txtid.Visible = True
txtpassword.Visible = True
End Sub
Protected Sub LoginShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginShow.Click
LinkButtonLogin.Visible = True
LoginShow.Visible = False
txtid.Visible = True
txtpassword.Visible = True
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
End Sub
Public Function ProcessMyDataItem(myValue As Object) As String
If myValue Is DBNull.Value Then
Return ""
End If
Return myValue.ToString()
End Function
Public Function ProcessMyDataItem2(myValue As Object) As String
If myValue Is DBNull.Value Then
Return ""
End If
Return myValue.ToString()
End Function
Public Function ProcessMyDataItem3(myValue As Object) As String
If myValue Is DBNull.Value Then
Return ""
End If
Return myValue.ToString()
End Function
End Class
Thank You ,
Noor Ahmed ,