Page view counter

How to insert a loginStatus control inside a tree view node

Last post 11-04-2008 2:52 PM by urir10. 5 replies.

Sort Posts:

  • How to insert a loginStatus control inside a tree view node

    10-29-2008, 4:08 PM
    • Loading...
    • urir10
    • Joined on 10-11-2007, 2:19 PM
    • Posts 146
    • Points 55

    I have a tree view menu that is populated from the sitemap based on the user role, at the end of the tree view i want to have a loginStatus control to enable users to logout.

    How can i do that?

  • Re: How to insert a loginStatus control inside a tree view node

    10-29-2008, 4:42 PM
    Answer
    • Loading...
    • anas
    • Joined on 09-21-2006, 4:31 AM
    • Ramallah, Palestine
    • Posts 6,115
    • Points 48,415
    • Moderator

     Hi,

    You have 2 solutions :

    1. Place the Login status control under the TreeView  control( outside the TreeView).
    2. Add Logout page ( e.g. : Logout.aspx ) , and add it to web.SiteMap file , Also you need to use the following code in Logout page , Place the code in its Page_Load method:

    FormsAuthentication.Signout();

    Response.Redirect(FormsAuthentication.LoginUrl);


    Regards,

    Anas Ghanem.


    Note:Please Don't hesitate to click "Alert Moderators" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

  • Re: How to insert a loginStatus control inside a tree view node

    10-30-2008, 11:55 AM
    • Loading...
    • urir10
    • Joined on 10-11-2007, 2:19 PM
    • Posts 146
    • Points 55

     Thanks anas i guesse that will work for me.

    Only thing i cant figure out now is how to disable the back button once the user is logged out. Lets i have my site and the user click logout , it will redirect him to the logout page and end his session, 

    but if the user clicks the back button it will go the last page that only logged in users can go ,if you click any link after you go back it will go to the login page but still i need to disable it from bieng able to go even one page back. How can i do that?

    And also another problem im facing is that after i logout, i created a logout page that says "you are now logged out" or whatever, and then i have a button to return to the login page. after i click that button and login again it opens the logout page right away. why is that?
  • Re: How to insert a loginStatus control inside a tree view node

    10-30-2008, 2:34 PM
    Answer
    • Loading...
    • anas
    • Joined on 09-21-2006, 4:31 AM
    • Ramallah, Palestine
    • Posts 6,115
    • Points 48,415
    • Moderator

    urir10:
    but if the user clicks the back button it will go the last page that only logged in users can go ,if you click any link after you go back it will go to the login page but still i need to disable it from being able to go even one page back. How can i do that?

    Try to disable page caching , Add this line to your page load ,

    Response.Cache.SetCacheability(HttpCacheability.NoCache)

    To avoid repeating that line , you can create a base calss for your pages , or if you are using master page ,you can just place that line in its Page_load method ,

     

    urir10:
    And also another problem im facing is that after i logout, i created a logout page that says "you are now logged out" or whatever, and then i have a button to return to the login page. after i click that button and login again it opens the logout page right away. why is that?

    Try to handle the Loggedin event for your login control , and place response.Redirect( your home page) code there .

    Regards,

    Anas Ghanem.


    Note:Please Don't hesitate to click "Alert Moderators" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

  • Re: How to insert a loginStatus control inside a tree view node

    10-30-2008, 3:34 PM
    • Loading...
    • urir10
    • Joined on 10-11-2007, 2:19 PM
    • Posts 146
    • Points 55

    Thanks anas 

    the first solution worked great, thanks

    but the second one im still stuck on. it logs in fine the first time and i can browse throu all the pages fine, then i logout and clear the session, it goes to the logout page and then i signout like you said in the pageload. I then click a button to go back to the logon page, i login and it goes directly to the logout page instead of the default .aspx file. Could it be because of my treeview control, maybe its storing the value of the last visted page or something?

    NVM   got it to work.  Thanks for your help anas!
  • Re: How to insert a loginStatus control inside a tree view node

    11-04-2008, 2:52 PM
    • Loading...
    • urir10
    • Joined on 10-11-2007, 2:19 PM
    • Posts 146
    • Points 55

     Now i got another question... :P

     When i have the user log in, i know his id and name. What they asking me now is to have the root node of the tree view to show the user id , and when clicked it should go to 

    the home page. How can i do that?

Page 1 of 1 (6 items)