重定向页面时出现问题 [英] Problem while redirecting pages

查看:76
本文介绍了重定向页面时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将页面从Page1重定向到Page2,然后再次使用Internet Explorer中的返回"按钮返回到Page1时,将调用Page1的Page_Load.但是,当我从Page2重定向到Page3时,以及当我返回时,Page2的Page_Load未被调用.同样,当我返回时,正在调用Page1的Page_Load.
以相反的顺序遍历时,只有第1页的Page_Load被调用.

第1页->第2页-> Page1 [Page1的Page_Load被称为]

第1页->第2页->第3页-> Page2 [未调用Page_Load]

第1页->第2页->第3页->第2页-> Page1 [Page1的Page_Load被称为]
a

解决方案

页面加载事件始终被触发.

如果没有得到page_load,这是因为某些东西(最有可能是浏览器)决定缓存页面.
也可以是服务器端缓存.

要解决您的问题,您必须告诉浏览器不要缓存该页面.

通常,您会添加页面加载量

 Response.Cache.SetCacheability(HttpCacheability.NoCache); 


嘿,亲爱的,

请在第3页的按钮单击事件中检查您的反向代码.
它可能有一些错误的代码.
我只是检查您想做的事情,它是否可以正常工作.
您在使用

 Responce.Redirect("Default2.aspx"); 


第3页上的按钮单击事件.


根据我的理解,您想导航到一页到另一页.

1)在页面(btn1,btn2,btn3)中添加3个按钮,现在在btn1下单击代码,如下所示
Response.Redirect("http://www.google.com");
单击按钮时,可以使用相同的方式为页面名称提供要导航的位置.
Response.Redirect("page1.aspx");

2)同样可以使用linkbutton的方法,将linkbutton->转到属性->将PostBackUrl值设置为要导航的页面
< asp:linkbutton runat ="server" id ="lnk1" postbackurl =〜/AboutUs.aspx" text =关于我们" xmlns:asp =#unknown">


After redirecting a page from Page1 to Page2 and again when I go back to Page1 using the "Back" button in the internet explorer, the Page_Load of Page1 is getting called. But When I redirect from Page2 to Page3, and When I go back, the Page_Load of Page2 is not getting called. Again when I go back, the Page_Load of Page1 is getting called.
Only the Page_Load of Page1 is getting called when traversed in the reverse order.

Page1 -> Page2 -> Page1 [Page_Load of Page1 is called]

Page1 -> Page2 -> Page3 -> Page2 [No Page_Load is called]

Page1 -> Page2 -> Page3 -> Page2 -> Page1 [Page_Load of Page1 is called]
a
How does this work, Could someone explain me?

解决方案

The page load event is always fired.

If you don''t get page_load this is because something (most probably the browser) decided to cache the page.
It could also be server side caching.

To fix your issues you must tell the browser not to cache the page.

Typically you''d add in your page load

Response.Cache.SetCacheability(HttpCacheability.NoCache);


Hey Dear,

Please check your reverse code in button click event of page 3.
It may have some wrong code.
I just check whatever you want to do and it working properly.
Are you using

Responce.Redirect("Default2.aspx");


on button click event of page 3.


as per my understanding you want to navigate to one page to other page.

1)Add 3 buttons in a page(btn1, btn2, btn3), now under btn1 click wrie the code as shown below
Response.Redirect("http://www.google.com");
same way you can give the page name where you want navigate when you click on button.
Response.Redirect("page1.aspx");

2)Same way you can use linkbutton also, add linkbutton -->go to the properties -->set the PostBackUrl value as your page where you want to navigate
<asp:linkbutton runat="server" id="lnk1" postbackurl="~/AboutUs.aspx" text="About Us" xmlns:asp="#unknown">


这篇关于重定向页面时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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