Hi, I am looking for a C# function to go back one page. I have a button on my form which I want when clicked to take the user back one page.
Any ideas as to how I can do that. I know I have to pass the C# function as a value to onClick attribute on my form. But how do I get the previous page???I dnont think that you can do it with C#, you should do it with JavaScript, if the button just going back one page and not performing any other processing.
<script language="javascript">
function goBack() {
history.back();
}
</script>Actualy you can (i think)
I just had a quick play: Request.UrlReferrer is what your after.
What you need to do is get that value on pageLoad (if ! postback) and store it in a hidden field.
if!postback: because when you click the button, it goes to pageLoad before the button function is called.
hidden field: this is because it's the oly way to pass variables (unless you use the ?Back=www.com). Then you get the value of the hidden field and Redirect to it.
Any ideas as to how I can do that. I know I have to pass the C# function as a value to onClick attribute on my form. But how do I get the previous page???I dnont think that you can do it with C#, you should do it with JavaScript, if the button just going back one page and not performing any other processing.
<script language="javascript">
function goBack() {
history.back();
}
</script>Actualy you can (i think)
I just had a quick play: Request.UrlReferrer is what your after.
What you need to do is get that value on pageLoad (if ! postback) and store it in a hidden field.
if!postback: because when you click the button, it goes to pageLoad before the button function is called.
hidden field: this is because it's the oly way to pass variables (unless you use the ?Back=www.com). Then you get the value of the hidden field and Redirect to it.