By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,574 Members | 2,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,574 IT Pros & Developers. It's quick & easy.

Make button invisible

P: n/a
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

Dec 11 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
--
Milosz Skalecki
MCAD
"shapper" wrote:
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

Dec 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.