为什么F5不尊重Panel控件的可见性? [英] Why does F5 not honour visibility of Panel controls?

查看:66
本文介绍了为什么F5不尊重Panel控件的可见性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个网页,我在其中使用几个面板来控制页面各部分的可见性。页面的母版页中 EnableViewstate 设置为false。



如果在第一次访问该页面时 PanelA 是可见的并且 PanelB 被隐藏,然后我在回发事件中交换它,我得到了预期的结果 - 即 PanelB 现在是可见的。到现在为止还挺好。但是,如果我现在点击 F5 刷新页面,我发现 PanelA 仍然隐藏, PanelB 仍然可见。



为什么页面不会恢复到初始默认状态?更令人费解的是,如果我在 Page_Load 中设置断点,我发现,按 F5 后,可见属性设置为I可以预期,返回默认状态, PanelA.Visible = true PanelB.Visible = false 。然而, PanelA 仍然隐藏, PanelB 仍然出现在屏幕上。



有谁知道我的意思我失踪了?



亲切的愿望~Patrick

Hi,

I have a web page in which I use a couple of panels to control visibility of sections of the page. EnableViewstate is set to false in the page's master page.

If, on the first visit to the page, PanelA is visible and PanelB is hidden, then I swap this in a postback event, I get the expected result - i.e. PanelB is now the visible one. So far so good. However, if I now hit F5 to refresh the page, I find that PanelA remains hidden and PanelB remains visible.

Why doesn't the page go back to its initial default state? Even more puzzling, if I put a breakpoint in the Page_Load even, I find that, upon pressing F5, the Visible property is set as I would expect, back in the default state, with PanelA.Visible=true and PanelB.Visible=false. Yet PanelA remains hidden and PanelB still appears on the screen.

Does anyone have any idea what I'm missing?

Kind wishes ~ Patrick

推荐答案

来自浏览器的F5(页面刷新)是完整的-post-back,表示它是您页面的新负载(而不是部分后退)。因此,您的页面将被渲染,因为它是第一次加载A可见且B隐藏!

如果您想在页面的加载(我的意思是新的满载)之间存储状态,您必须保持州 - 可能使用cookies ...
F5 (page refresh) from browsers are do full-post-back, means it's a new load of your page (and not a partial-post-back). So your page is rendered as it was it's first load A visible and B hidden!
If you want to store state between loads (I mean new an full loads) of your page ,you have to maintain that state - maybe using cookies...


这篇关于为什么F5不尊重Panel控件的可见性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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