G
Guest
Hi all!
Here's the situation
I have a frame set with 3 frames, banner, contents and main.
I have my login.aspx in banner and after login, I redirect back to
index.aspx where my frameset at.
There should be some change on banner and main but it didn't happen, I need
to press F5 in order for the change to take place.
Here's the change:
banner : disable login button and enable logout button
main : change the frame source to other page.
Why is this happening?
Thanks in advance.
codes of banner.aspx
************************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("login") = True Then
lblResult.ForeColor = System.Drawing.Color.Black
lblResult.Text = "Welcome, " & Session("name") & "!"
If lblResult.Visible = False Then
lblResult.Visible = True
End If
If btnLogout.Enabled = False Then
btnLogout.Enabled = True
End If
If btnLogin.Enabled = True Then
btnLogin.Enabled = False
End If
End If
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
Dim Conn As SqlConnection
Dim Reader As SqlDataReader
Dim Cmd As New SqlCommand
Try
Conn = New
SqlConnection("server=(local);Trusted_Connection=yes;database=Attendance")
Conn.Open()
Cmd.Connection = Conn
Cmd.CommandText = "SELECT * FROM Staff WHERE StaffID='" &
txtStaffID.Text.Trim & "'"
Reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
If Not Reader.HasRows Then
If lblResult.Visible = False Then
lblResult.Visible = True
End If
lblResult.ForeColor = System.Drawing.Color.Red
lblResult.Text = "Invalid Login Datas!"
Else
Reader.Read()
If Reader.GetValue(5) = txtPassword.Text.Trim Then
Session("id") = Reader.GetValue(5)
Session("login") = True
Session("name") = Reader.GetValue(1)
Response.Redirect("index.aspx", False)
Else
Session("login") = False
End If
End If
Catch ex As Exception
Session("err") = ex.ToString & "<br>" & ex.HelpLink
Response.Redirect("error.aspx")
Finally
Conn.Close()
Cmd.Dispose()
End Try
End Sub
************************************************************
codes of index.aspx
************************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("login") = True Then
main.Attributes("src") = "link.aspx"
End If
End Sub
************************************************************
Here's the situation
I have a frame set with 3 frames, banner, contents and main.
I have my login.aspx in banner and after login, I redirect back to
index.aspx where my frameset at.
There should be some change on banner and main but it didn't happen, I need
to press F5 in order for the change to take place.
Here's the change:
banner : disable login button and enable logout button
main : change the frame source to other page.
Why is this happening?
Thanks in advance.
codes of banner.aspx
************************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("login") = True Then
lblResult.ForeColor = System.Drawing.Color.Black
lblResult.Text = "Welcome, " & Session("name") & "!"
If lblResult.Visible = False Then
lblResult.Visible = True
End If
If btnLogout.Enabled = False Then
btnLogout.Enabled = True
End If
If btnLogin.Enabled = True Then
btnLogin.Enabled = False
End If
End If
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
Dim Conn As SqlConnection
Dim Reader As SqlDataReader
Dim Cmd As New SqlCommand
Try
Conn = New
SqlConnection("server=(local);Trusted_Connection=yes;database=Attendance")
Conn.Open()
Cmd.Connection = Conn
Cmd.CommandText = "SELECT * FROM Staff WHERE StaffID='" &
txtStaffID.Text.Trim & "'"
Reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection)
If Not Reader.HasRows Then
If lblResult.Visible = False Then
lblResult.Visible = True
End If
lblResult.ForeColor = System.Drawing.Color.Red
lblResult.Text = "Invalid Login Datas!"
Else
Reader.Read()
If Reader.GetValue(5) = txtPassword.Text.Trim Then
Session("id") = Reader.GetValue(5)
Session("login") = True
Session("name") = Reader.GetValue(1)
Response.Redirect("index.aspx", False)
Else
Session("login") = False
End If
End If
Catch ex As Exception
Session("err") = ex.ToString & "<br>" & ex.HelpLink
Response.Redirect("error.aspx")
Finally
Conn.Close()
Cmd.Dispose()
End Try
End Sub
************************************************************
codes of index.aspx
************************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("login") = True Then
main.Attributes("src") = "link.aspx"
End If
End Sub
************************************************************