ViewState with example in asp.net C#

Tuesday, December 21, 2010

Coding of LogOut Button in asp.net C#.

Coding of LogOut Button in asp.net C#.


you can use logout button in your master page.
Step1-: First be remove the cache in load event of master page. like describe below.




 protected void Page_Load(object sender, EventArgs e)
    {     
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
    }



Step2:- Now write the below code in click event of link button.


       protected void lnk_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        
        Response.Redirect("~/Home.aspx");
    }

Coding of master page. 

public partial class InMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {     
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
    }
    protected void lnk_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        
        Response.Redirect("~/Home.aspx");
    }
}

7 comments:

  1. i didnt use master page, i am giving separate page for each form, then how to use this... suggest some idea

    ReplyDelete
  2. if i click on back button of web browser after sign out it comes the looged page again why..can u sugess any idea

    ReplyDelete
  3. please give the complete code so that if the user click the Log-Out button and then if click the back button of browser (at top left corner of the browser) the error message is flashed out.
    Please provide the suitable code(that you have tested itself),and where to write that code, at my email id "rjshkumargupta@gmail.com"
    Thanks in advance....

    ReplyDelete
  4. please give the complete code so that if the user click the Log-Out button and then if click the back button of browser (at top left corner of the browser) the error message is flashed out.
    Please provide the suitable code(that you have tested itself),and where to write that code, at my email id "rjshkumargupta@gmail.com"
    Thanks in advance....

    ReplyDelete
  5. plz send full logout code in c#

    ReplyDelete
  6. full logout code in c# plz

    ReplyDelete