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.
Asked
Active
Viewed 2,887 times
0
-
This question is way too ambiguous, are you talking about ASP.NET, WPF navigation, or something else? What are you expecting this back button to do, and what is it doing instead? – joshperry Dec 21 '09 at 05:01
-
i want it to return to the previous page just like the back button at the top of the browser does.... – Selase Dec 21 '09 at 05:46
-
i try to use a response .redirect but it validates the page first and i dont want that to happen..i just want it to return just like the back button at the top of the browser.. some one recomended page.previous page but i get an error that says"only assignment,call,ikncrement and new object expressions can be used as a staement" how can i work it ou.? – Selase Dec 21 '09 at 05:50
2 Answers
0
Use can use the
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
- 184,426
- 49
- 232
- 263
-
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 Dec 21 '09 at 05:16
0
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
- 254
- 2
- 3