views:

395

answers:

3

I'm trying to code a back event in C# into a button click event, but I cant find the right steps. I am using Visual Studio 2008.

A: 

Use can use the

Page.PreviousPage

to get the page that transferred control to the current page.

When you use the Transfer method or use cross-page posting to transfer processing from one ASP.NET page to another, the originating page contains request information that might be required for the destination page. You can use the PreviousPage property to access that information

If the current page is being rendered as a result of a direct request (not a transfer or cross-post from another page), the PreviousPage property contains nullNothingnullptra null reference (Nothing in Visual Basic).

rahul
am i supposed to put that in the button click method..?cus i did an i get a blue line under it with the error that says only assignment,call,ikncrement and new object expressions can be used as a staement..what might be going wrong?
Selase
A: 

One approach that can be used is to use the javascript history method:

    protected void Button1_Click(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "My Unique Key", "<script>history.go(-2)</script>");

    }
Subbu
A: 

Great Thanks for your help..

andy