Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi,

I Created a web form(first page) .It contains some details about a person and a print

button.I click the print button it go to second page .This page will get the crystal report.I

clicked the print button on the report and show preview of crystal report print and take

the print.second page also contain back button. I need when click the back button it go to

first page without reloading.but I click the back button it go to previous state of current

page. Because second page was more time reloaded .

Can I go to first page when I click the back button in first time?

I place th belowcode in pageload.

this.Lbtnback.OnClientClick = "window.history.go(-1);return false;";
Posted
Updated 2-Oct-10 4:19am
v2
Comments
Sunasara Imdadhusen 1-Oct-10 8:26am    
Please provide more clarification over you question?
what you exactly want like you have to go Back as like Browser button or else Redirection using Response.Redirect?
Sandeep Mewara 1-Oct-10 11:56am    
More info from OP: i am trying create a back button in my code. i want to go to specific page when i click on it and that page should not refresh because some details entered in that page i tried history.go("url") but it's not working is there any other way to do this.

Please make your question clear.
// go back to previous page
<input type=button value="back" onclick='history.go(-1)'>

Response.Redirect("PreviousPage.aspx");
 
Share this answer
 
hi,

I Created a web form(first page) .It contains some details about a person and a print

button.I click the print button it go to second page .This page will get the crystal report.I

clicked the print button on the report and show preview of crystal report print and take

the print.second page also contain back button. I need when click the back button it go to

first page without reloading.but I click the back button it go to previous state of current

page. Because second page was more time reloaded .

Can I go to first page when I click the back button in first time?

I place the belowcode in pageload.

this.Lbtnback.OnClientClick = "window.history.go(-1);return false;";
 
Share this answer
 
Pass page path (with querystring) so you know where you came from to this page.. and on back button put something like this
<code>
<asp:Button runat="server" ID='btnBack' OnClientClick="fnJSgotoPrevious(<%= PreviousPage %>);return false;" />
</code>
then you have to define a JS on your page
<code>
<script language="javascript">
function fnJSgotoPrevious(previousPage)
{
document.window.location.href=previousPage;
}
</script>
</code>
in your code behind define this property
<code>
protected string PreviousPage
{
get { return Request.QueryString("PreviousPage");}
}
</code>
and when you call this page you have to pass extra parameter in previouspage now..
something like this
<code>
Response.Redirect("ReportPage.aspx?PreviousPage=ThisPageName.aspx");
</code>
 
Share this answer
 
 
Share this answer
 
Hi
You can try following:

C#
<a href="javascript:history.go(-1)">Go back</a>


Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900