老年问题:刷新按钮导致回发 [英] Old Age Problem: Refresh Button Causes Postback

查看:57
本文介绍了老年问题:刷新按钮导致回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个老问题,但我之前从来没有这么糟糕,

单击浏览器刷新按钮时事件正在重新启动。

In在我的webform中的Submit按钮,我捕获服务器端点击

事件并更新会话信息以跟踪向导类型导航中某些

面板的可见性("接下来>>"和<<< Back"按钮)..

但是刷新按钮会触发另一个事件并将整个

的事情带到一个Choes ..


重定向到数据库中的同一页面/保存状态是愚蠢的,并且

不应该被提及作为答案..并且,请,如果你猜不到,请不要回复。


谢谢。

解决方案

这是更多的咆哮,而不是对正在发生的事情的解释和

你的问题真的是什么....


当你点击刷新,你没有造成一个postb ACK。您正在重新创建

页面类,因此,它的New,Init,LoadViewState,

序列。这是因为Web的无状态特性,而不是ASP.NET。


提交表单数据时会发生PostBack。刷新并不总是

完成此任务。


您遇到的问题究竟是什么?请原谅我,如果这听起来很讽刺(这真的不是那种意思),但是我的经验是,

a更好地理解Page class'的生命周期可以消除关于回发的问题。

" tasmisr" < TA ***** @ hotmail.com>在消息中写道

news:ff ************************** @ posting.google.c om ...

这是一个老问题,但我之前从来没有这么糟糕,
点击浏览器刷新按钮时事件正在重新启动。
在提交按钮在我的webform中,我捕获服务器端单击
事件并更新会话信息以跟踪向导类型导航(Next>>和< ;< Back"按钮)..
但是刷新按钮会使另一个事件触发并将整个事情带给Choes ..

重定向到同一页面/保存数据库中的状态是愚蠢的,不应该提到答案..如果你猜的话,请不要回复。

谢谢。


我知道你正在努力帮助。

我完全理解页面对象的生命周期但是我会

推荐t你逐步通过调试器并单击刷新

按钮,看看会发生什么,刷新按钮重新提交数据到服务器上的服务器与提交表单完全相同第一次。

请不要因为提交这些新闻组而得到

无用的答案,所以如果你不知道的话,不要回答!


这里是答案,使用ViewState保留信息而不是

的Session对象。


This is an old problem,, but I never had it so bad like this before,,
the events are refiring when clicking the Browser refresh button.
In the Submit button in my webform, I capture the server side click
event and I update session information to track the visibilty of some
panels in a wizard type navigation ("Next >>" and "<< Back" buttons)..
but the refresh button makes another event firing and takes the whole
thing to a Choes..

redirection to the same page/ saving state in a database is dumb and
should not be mentioned as an answer .. and Please, don''t reply if you
are guessing.

thanks.

解决方案

This is more ranting and less of an explanation of what is happening and
what your problem really is....

When you hit refresh, you are not causing a postback. You are causing the
page class to be re-created and therefore, its New, Init, LoadViewState,
Page_Load , SaveViewState, control events and unload events are fired in
sequence. This is because of the stateless nature of the web, not ASP.NET.

PostBack occurs when form data is submitted. A refresh does not always
accomplish this.

What exactly is the problem you are experiencing. Pardon me if this sounds
sarcastic (it really isn''t meant that way), but it''s been my experience that
a better understanding of the Page class''s lifecycle serves to eliminate
questions regarding postback.
"tasmisr" <ta*****@hotmail.com> wrote in message
news:ff**************************@posting.google.c om...

This is an old problem,, but I never had it so bad like this before,,
the events are refiring when clicking the Browser refresh button.
In the Submit button in my webform, I capture the server side click
event and I update session information to track the visibilty of some
panels in a wizard type navigation ("Next >>" and "<< Back" buttons)..
but the refresh button makes another event firing and takes the whole
thing to a Choes..

redirection to the same page/ saving state in a database is dumb and
should not be mentioned as an answer .. and Please, don''t reply if you
are guessing.

thanks.



I know you are trying to help.
I fully understand the life cycle of the page object but I would
recommend that you step through the debugger and click the refresh
button and see what happens, the refresh button resubmits the data to
the server exactly the same as submitting the form for the first time.
Please I''m sick of submitting to these newsgroups and getting
nonhelpful answers, SO DON''T ANSWER IF YOU DON''T KNOW!


And here is the answer, to use a ViewState to retain the info instead
of the Session object.


这篇关于老年问题:刷新按钮导致回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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