hi all.
How can i get my page_unload event in c#

In your code view just type override then space then find OnInit or OnLoadComplete then click Tab to complete the code.

Here is the example:

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
    }
    protected override void OnLoadComplete(EventArgs e)
    {
        base.OnLoadComplete(e);
    }

you dont have to override anything, notice that your .aspx page have :

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

AutoEventWireup is set to true by default, which means you dont need to wire your events, just write your event handler functions and they will be registered automatically. The code below writes three lines of text to a file using Page_Unload event handler.

using System;
using System.IO;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Page_Unload(object sender, EventArgs e)
    {
        // Compose a string that consists of three lines.
        string lines = "First line.\r\nSecond line.\r\nThird line.";

        // Write the string to a file.
        System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
        file.WriteLine(lines);

        file.Close();
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.