Make button invisible

S

shapper

Hello,

I have a link button which signs out the user when it is clicked.

I place on by button the code line ibLogout.Visible =
My.User.IsAuthenticated.

So, when the user is authenticated the button logout is visible.
Otherwise is invisible.

There is a problem:

When I click logout the button does not get invisible. I need to
click it again or refresh the page so it takes effect.

Could someone, please help me out with this?

I believe this has something to do with the load, init, etc events.

Here is my code:

1 Private Sub lbLogout_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles lbLogout.Load
2 With lbLogout
3 .ID = "lbLogout"
4 .Text = "logout"
5 .Visible = My.User.IsAuthenticated
6 End With
7 End Sub
8 Private Sub lbLogout_Click(ByVal sender As Object, ByVal e As
EventArgs) Handles lbLogout.Click
9 FormsAuthentication.SignOut()
10 End Sub ' lbLogout_Click

Thank You,

Miguel
 
G

Guest

Howdy,

It's obvious because you're setting visibility on page_load event handler,
and you're calling FormsAuthentication.SignOut()
in the lbLogout_Click which occurs after Page_Load event (visibility is
already set).
You have to set visibility again:

1 Private Sub lbLogout_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles lbLogout.Load
2 With lbLogout
3 .ID = "lbLogout"
4 .Text = "logout"
5 .Visible = My.User.IsAuthenticated
6 End With
7 End Sub
8 Private Sub lbLogout_Click(ByVal sender As Object, ByVal e As
EventArgs) Handles lbLogout.Click
9 FormsAuthentication.SignOut()
lbLogout.Visible = False
10 End Sub ' lbLogout_Click

Hope this helps
 

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,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top