473,394 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

IsPostBack but in ASP

Seb
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien


Oct 3 '07 #1
6 8403
"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien
Function IsPostBack()
IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function


--
Anthony Jones - MVP ASP/ASP.NET
Oct 4 '07 #2
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien

"Anthony Jones" wrote:
"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien

Function IsPostBack()
IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function


--
Anthony Jones - MVP ASP/ASP.NET
Oct 4 '07 #3
"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Will something lke this work for you?

It uses Session variables to identify the current page
and its counter.

Create "refresh1.asp" then copy it to "refresh2.asp"
and change the value of "cASP" to "refresh2.asp".

Call it via http://{your domain}/refresh1.asp then
click the links and watch the page+counter display.
Clicking "Refresh" will increment the counter as well.

<%@ Language="VBScript" %>
<% Option Explicit
Const cASP = "refresh1.asp"
If Session("ASP") <cASP _
Or Session("CTR") = "" Then
Session("CTR") = 0
Else
Session("CTR") = Session("CTR") + 1
End If
Session("ASP") = cASP
%>
<html>
<body>
<%=Session("ASP")%: <%=Session("CTR")%>
<hr>
<a href="refresh1.asp">1</a| <a href="refresh2.asp">2</a>
</body>
</html>
Oct 4 '07 #4
?
Not even .Net's IsPostBack method can distinguish between an initial
page request and a subsequent page refresh ...

To do that, you will probably need to use a session variable to track
when the page is initially requested

Seb wrote:
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien

"Anthony Jones" wrote:
>"Seb" <a@a.frwrote in message
news:47***********************@news.free.fr...
>>Hello,

Is there the IsPostBack command in ASP (not ASP.net) ?
Or How can I detect a refresh in a ASP page ?
Thanks

Sebastien

Function IsPostBack()
IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function


--
Anthony Jones - MVP ASP/ASP.NET
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 4 '07 #5
"Seb" <Se*@discussions.microsoft.comwrote in message
news:F6**********************************@microsof t.com...
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien
I see. Most refreshes are accompanied with a pragma: no-cache header but
that isn't guaranteed nor is it guaranteed that the initial request will not
be accompanied by the header.

The best way to ensure you don't reprocess the same post is to add a hidden
field containing a unique ID (such as a GUID) to the form.

When you've processed the POST of the form make a record of the UniqueID to
mark that its been processed. Before processing a POST check that you
haven't got a record of that POST already.

--
Anthony Jones - MVP ASP/ASP.NET
Oct 4 '07 #6
Thank you everybody

Finally I have used a Session variable to save the last post but it's not a
unique ID because my unique ID is calculated when I have a new post.

By
Sébastien
"Anthony Jones" wrote:
"Seb" <Se*@discussions.microsoft.comwrote in message
news:F6**********************************@microsof t.com...
Hello

Sorry but it's good to detect a POST but not to detect a refresh.

Thanks

Sebastien

I see. Most refreshes are accompanied with a pragma: no-cache header but
that isn't guaranteed nor is it guaranteed that the initial request will not
be accompanied by the header.

The best way to ensure you don't reprocess the same post is to add a hidden
field containing a unique ID (such as a GUID) to the form.

When you've processed the POST of the form make a record of the UniqueID to
mark that its been processed. Before processing a POST check that you
haven't got a record of that POST already.

--
Anthony Jones - MVP ASP/ASP.NET
Oct 5 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tim | last post by:
To make !Page.IsPostBack to work, do I need to set any properties at page level or in the config files(Web, machine) or aspx files. Because code in under the !IsPostBack is executing twice and...
2
by: patrick_a | last post by:
Hi, I'm having trouble with using !IsPostBack. I want to create a linkbutton within a table when the page loads the first time and then have the page redirect based on the...
3
by: Alan Pretre | last post by:
I have a a WebForms.Table control that I am populating in Page_Load(). One of the columns has cells with a button in each row, which I wire up to its Click event handler. Everything is fine if I...
2
by: Pravin | last post by:
Hi, I have a doubt that how does ASP.NET find out whether the page is accessed for the first time or the page is due to a post back event, and then set the IsPostBack property ? Any ideas. ...
2
by: Anand Sagar | last post by:
I have a Panel1 and button1 on my webform. At runtime, I create 2 textboxes. I do it at the Page_Load event. I put the code within the " If Not isPostBack" For the button click event, I will do...
4
by: TJ | last post by:
Hi, There is one aspx web page that contains usercontrol. In aspx page and usercontrol , there is each submit button... Here is what I want... I want to process something depending on each...
6
by: RA | last post by:
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load. If I don't have IsPostBack check; I am able to debug through btnAdd_Click. If I don't look for IsPostBack then it...
5
by: David Lozzi | last post by:
Hello, I have an interesting issue, so bear with me as I try to explain. I have a datalist posing as tabs for my application. And as each tab is clicked, a placeholder is then populated with the...
0
by: DC | last post by:
Hi, I am dynamically adding a usercontrol that uses "this.IsPostBack" in Page_Load to decide whether it must populate some of it's inner controls or not. Since I am adding the usercontrol to the...
5
by: BM | last post by:
I have a question that seems like it should have a simple answer, but I can't seem to find it by searching... Anyway, I'm trying to capture the IsPostBack event when I select an item within an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.