Need help with page reload

G

Guest

I need to implement a login/logout feature (for a school assignment). I am using forms authentication. I have an index.html with frames: "top", "side", "main", "bottom". The top frame has a navigation bar with an asp hyperlink. I would like the text for this link to change from "Login" to "Logout" when the user logs in. So I put this code in the Page_Load of Top.aspx:
If User.Identity.IsAuthenticated Then
lnkLogin.Text = "Logout"
Else
lnkLogin.Text = "Login"
End If

In my Login.aspx.vb I have the following code in my btnLogin_Click:
RegisterStartupScript("Reload", "<SCRIPT Language='Javascript'>parent.top.document.Form1.submit()</" & "Script>").

The text for the hyperlink does NOT change when the user succesfully logs in. What am I doing wrong?

If anyone has a better way of accomplishing the same thing, if it's not too complicated :), I would love to hear it!

Thank you,
Judy
 
R

Rick Spiewak

You don't show the rest of your code, but probably the problem is that the
lnkLogin click event is occurring after the page load event. Set breakpoints
to verify this - and then change the text in the lnklogin click event.

Judy Ward said:
I need to implement a login/logout feature (for a school assignment). I
am using forms authentication. I have an index.html with frames: "top",
"side", "main", "bottom". The top frame has a navigation bar with an asp
hyperlink. I would like the text for this link to change from "Login" to
"Logout" when the user logs in. So I put this code in the Page_Load of
Top.aspx:
If User.Identity.IsAuthenticated Then
lnkLogin.Text = "Logout"
Else
lnkLogin.Text = "Login"
End If

In my Login.aspx.vb I have the following code in my btnLogin_Click:
RegisterStartupScript("Reload", "<SCRIPT
Language='Javascript'>parent.top.document.Form1.submit() said:
The text for the hyperlink does NOT change when the user succesfully logs in. What am I doing wrong?

If anyone has a better way of accomplishing the same thing, if it's not
too complicated :), I would love to hear it!
 
G

Guest

Yes, the btnLogin_Click event happens after Page_Load. I have also tried putting the "Reload" code under the Page_Load event--that didn't work either. The user isn't authenticated until the button is clicked.

When you say, "change the text in the lnklogin click event", do you have any suggestions?

Thank you,
Judy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top