C# – how to logout in windows mobile based application

ccompact-frameworkwindows-mobile

I am developing an application for windows mobile in which I have a logout functionality at each form I open.

So while pressing the logout button I am able to delete the username password from the memory but I am not able to drag the user to the login screen again while freeing all the memory and closing all the forms.

Anybody knowing the answer plz help me out.

Best Answer

Try this. Your main form becomes a "shell" with a logout button (or possibly you do that via a MainMenu object). Then rewrite your other forms into UserControls instead. Then when the user "moves" to a new page just initialise the usercontrol and slap it into the .Controls collection in your shell form (oh and remove the current one first :) ).

Technically you always remain on the first form this way, you don't need to duplicate the logout code/UI and moving the user back to the login page is easy, just remove the "Current" usercontrol and replace it with the "Login" user control.