Old Age Problem: Refresh Button Causes Postback

T

tasmisr

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.
 
S

Scott M.

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.
 
T

tasmisr

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!
 
T

tasmisr

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

Scott M.

Wow, you make me want to spend some time on your problem and help you out!

I stated in my last message: "PostBack occurs when form data is submitted.
A refresh does not always
accomplish this." This is true. If no data was submitted prior to the
refresh, then there is no data to repost. I said this in my first message
but you only tested it under one particular circumstance.

Are you sure you didn't write your "answer" backwards? Did you mean use
Session instead of ViewState? This would get around your re-posting problem
(since ViewState is on by default), but you now have to be very careful
since the session can be disabled by the client (session cookies) and the
server. Even if sessions are not disabled, they do take up overhead on the
server and if you are expecting any kind of significant volumne for the
page, they may not be the best solution.

Lastly, a word or 2 for you...I posted a reply to you and mentioned that
your post was not clear and that you needed to be more specific about what
problem you were having. You response was: "Please I'm sick of submitting
to these newsgroups and getting nonhelpful answers, SO DON'T ANSWER IF YOU
DON'T KNOW!"

So I guess I have this to say, "Please, I'm sick of reading posts that
aren't clear about what the problem is and are nothing more that venting
frustration at the rest of us, SO DON'T POST QUESTION IF YOU DON'T EXPLAIN
WHAT THE PROBLEM IS!"
 
G

g pavlov

Please I'm sick of submitting to these newsgroups and getting
nonhelpful answers, SO DON'T ANSWER IF YOU DON'T KNOW!

Hey, pal, chill out! Nobody OWES you anything here. People are posting
mostly out of the goodness of their hearts. If you are "sick" of it,
no one is forcing you to post! There are alternatives you know--here
are a few: post to a different group, don't post at all, call MS tech
support, buy a book on ASP.NET (and read it), read the MSDN help
files, hire someone else to do your job, don't do development in this
technology, get out of software development altogether... A quick
Google Groups search of the posts made from your email address shows
that people have been helpful to you more often than not.
 
T

tamer yousef

People are posting mostly out of the goodness of their >>hearts.

I guess not, some people are not, they just don't understand the
technology and they are posting messages to build a community
existance.. I don't care about this but what I care about is when u look
at the threads summary (before u click on the thread)and u find at least
2 replies for a thread, u will think that someone already helped which
is not true.. This happens all the time on Google groups.. I originally
posted my question on google but this forum is linked somehow to it..

And Scott M: If you have enough expreince you would have understood my
question from the first post.

back to the topic: yes, I solved it by using ViewState to instead of the
Session object,I meant the ViewState collection of the page object like:
ViewState("key") = value
this way when you refresh, it will call the origianl value of the
ViewState("key") even it was modified after the first submission.

Tamer
 
S

Scott M.

tamer yousef said:
I guess not, some people are not, they just don't understand the
technology and they are posting messages to build a community
existance.. I don't care about this but what I care about is when u look
at the threads summary (before u click on the thread)and u find at least
2 replies for a thread, u will think that someone already helped which
is not true.. This happens all the time on Google groups.. I originally
posted my question on google but this forum is linked somehow to it..

And Scott M: If you have enough expreince you would have understood my
question from the first post.


Don't blame me because you can not express yourself. I asked you in my
reply to be more clear about what problem you were having, your response was
that my answer was incorrect. I didn't give an answer, because you had not
supplied a question. I supplied general information about the page class
lifecycle in the hopes that this small amount of information could help you.
By the way, "you're welcome".
back to the topic: yes, I solved it by using ViewState to instead of the
Session object,I meant the ViewState collection of the page object like:
ViewState("key") = value
this way when you refresh, it will call the origianl value of the
ViewState("key") even it was modified after the first submission.

Why are you saying "instead of the Session object" when no one had suggested
the session object in the first place?

This is what I mean, you have been unclear about what you need, what you are
trying to do and what your attempts at a solution have been. This is one of
the basic tenants of how these NG's work. If it is frustrating to you that
the people who take their valuable time can't give you an answer based on
your vauge ranting, then you need to take the advice of "g pavlov"!

You've made a lot of friends here I can tell you!
 
T

tamer yousef

Don't blame me because you can not express yourself. I >asked you in my
reply to be more clear about what problem >you were having, your
response was
that my answer was incorrect.

U keep saying that my question was not clear, here is the original
question one more time:
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..

The refresh Button has a known problem of re-submitting the data. AND AS
YOU CAN READ I CLREALY mention using the SESSION object to keep track of
a submission status, again if you have experienced this problem in a
real solution you would have know how to solve it without saying to me
in your second post:
This is more ranting and less of an explanation of what >is happening and
what your problem really is....

and what make it worse, is that you started explaining the life cycle of
the page object and I clearly said in my first post:
event

which means that I did submit data, but you replied by:
If no data was submitted prior to the
refresh, then there is no data to repost

So you are creating your own hypothetical problem and solving it.. this
doesn't really help!
I would say it if it was my bad but clearly not, it's your
replies(which I call answers) that are not related to the problem.
Go check online on this Refresh problem and you will see how clearly
everybody know about it and nobody have given a solution for it(other
than the 2 soultions I mentioned in my first post).

I want you next time when you have a critical problem in your program to
think back about this thread and get the feeling of being stuck and
wasting your time in a thread like.. and yah u'r right, I made 2 friends
here..
 
S

Scott M.

U keep saying that my question was not clear, here is the original
question one more time:

There is nothing here that tells us what you are storing in session. Was is
data submitted from the form? Was it data that is related to the data
submitted from the form? UNCLEAR what you are doing with session. I'm
sorry if you feel that this is a complete explanation of what you are doing,
but the fact is, that it isn't even close!
The refresh Button has a known problem of re-submitting the data. AND AS
YOU CAN READ I CLREALY mention using the SESSION object to keep track of
a submission status, again if you have experienced this problem in a
real solution you would have know how to solve it without saying to me
in your second post:

Here is another example of your contempt. I usually don't insult the people
trying to help me. Now to business....There is (and never was) a known
"problem" with the refresh button. The way the refresh button works is a
matter of how HTML works and if you had any REAL experience with HTML, you
would know that. It's not a bug, it's by design.
and what make it worse, is that you started explaining the life cycle of
the page object and I clearly said in my first post:

event

which means that I did submit data, but you replied by:


So you are creating your own hypothetical problem and solving it.. this
doesn't really help!

No, you are taking what I said out of context to server your own arrogance!
You said: "the refresh button resubmits the data to
the server exactly the same as submitting the form for the first time" and I
corrected you by saying that "PostBack occurs when form data is submitted.
A refresh does not always accomplish this." which is ABSOLUTELY TRUE, if you
had any REAL experience with ASP.NET, you'd know that.
I would say it if it was my bad but clearly not, it's your
replies(which I call answers) that are not related to the problem.
Go check online on this Refresh problem and you will see how clearly
everybody know about it and nobody have given a solution for it(other
than the 2 soultions I mentioned in my first post).

Again, this is not a problem, which is why no one is giving you a solution.
You've been very clear from the beginning what you DON'T want to hear. By
being ignorant like this ("redirection to the same page/ saving state in a
database is dumb and
should not be mentioned as an answer") tells us all that it is YOU who has
no real practical experience with ASP.NET / HTML.
I want you next time when you have a critical problem in your program to
think back about this thread and get the feeling of being stuck and
wasting your time in a thread like.. and yah u'r right, I made 2 friends
here..

And I wish that the next time you extend your hand to help someone, that
they bite it right off!!
 
T

tamer yousef

Real funny, I have enough understanding and practical experince with
HTML and .Net.
If you don't understand the question don't create your own assumptions
and answers for these assumptions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top