The big problem is, because this entire process is stateless, the server
doesn't notice events like these. What you could do is create a new base
class for all your pages based on the normal Page class, but have it check
to determine the name of the script being called (using the
HttpContext.Current.Request objects collections) and if it isn't this page
you can delete the relevant files.

Instead of saving it as file, why not just add it to the viewstate for that
page. When they navitage away from the page it won't matter anymore as the
state won't be held.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Sudha" <Sudha_s@mailcity.com> wrote in message
news:022101c33b4f$e7317860$a501280a@phx.gbl...
> Hi,
>
> I have a datagrid control on my page. I navigate through
> the records using datagrid pagination. I get the records
> from the dataset when the user first queries for certain
> records. I then store the dataset into an xml file and use
> that xml file to display records when user clicks next or
> prev button in the datagrid. My problem is I need to
> delete that xml file when the user navigates away from
> that page. for eg my datagrid is in a search tab. When the
> user clicks Home tab or any other tab I need to remove
> that xml file from the disk. I used Page_Unload method
> but, it is fired when the user clicks Next or Prev button
> also. How should I remove a file when the user navigates
> to another page???
>