如何在asp.net中创建后退按钮 [英] how to create back button in asp.net

查看:87
本文介绍了如何在asp.net中创建后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个Web表单(第一页).其中包含有关人和打印品的一些详细信息

按钮.单击打印按钮转到第二页.此页面将显示水晶报表.I

单击报表上的打印"按钮,并显示水晶报表打印和预览的预览

print.second页面还包含后退"按钮.我需要在单击后退"按钮时转到

第一页而无需重新加载.但是我单击后退按钮,它会返回到当前的先前状态

页.因为第二页的刷新时间更长.

第一次单击后退按钮时可以转到首页吗?

我将以下代码放在页面加载中.

this.Lbtnback.OnClientClick ="window.history.go(-1); return false;";



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;";

推荐答案

请明确您的问题.
Please make your question clear.
// go back to previous page
<input type=button value="back" onclick=''history.go(-1)''>

Response.Redirect("PreviousPage.aspx");




我创建了一个Web表单(第一页).其中包含有关人和打印品的一些详细信息

按钮.单击打印按钮转到第二页.此页面将显示水晶报表.I

单击报表上的打印"按钮,并显示水晶报表打印和预览的预览

print.second页面还包含后退"按钮.我需要在单击后退"按钮时转到

第一页而无需重新加载.但是我单击后退按钮,它会返回到当前的先前状态

页.因为第二页的刷新时间更长.

第一次单击后退按钮时可以转到首页吗?

我将下面的代码放在页面加载中.

this.Lbtnback.OnClientClick ="window.history.go(-1); return false;";


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;";


传递页面路径(带有查询字符串),以便您知道来自此页面的位置..并在后退按钮上放置类似这样的内容
< code>
< asp:Button runat ="server" ID ="btnBack" OnClientClick ="fnJSgotoPrevious(<%= PreviousPage%>);返回false;" />
</code>
那么您必须在页面上定义一个JS
< code>
< script language ="javascript">
函数fnJSgotoPrevious(previousPage)
{
document.window.location.href = previousPage;
}
</script>
</code>
在后面的代码中定义此属性
< code>
受保护的字符串PreviousPage
{
获取{return Request.QueryString("PreviousPage");}
}
</code>
并且当您调用此页面时,您现在必须在上一页中传递额外的参数..
像这样的东西
< code>
Response.Redirect("ReportPage.aspx?PreviousPage = ThisPageName.aspx");
</code>
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>


这篇关于如何在asp.net中创建后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆