473,399 Members | 4,177 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,399 software developers and data experts.

alert box and problem with back button

hi,

I wrote a function like this :

public static void Alert(string message){
message=message.Replace("'","\'");

message=message.Replace("\n","\\n");

Response.Write("<script>alert('"+message+"');</script>");

}

this function is showing an alert box when necessary but when the user
navigate to another page and click back button of the browser then the last
error message shown again (as excepted because script is written top of the
page) but is there an event that I can capture if the user navigates to the
page first time ? and disable showing of the error ? ) I want a simple way I
solve this by using client time , server time etc.


Nov 18 '05 #1
3 4990

Selam Ersin,

When you click on the back button of the browser, the browser simply loads
the page from its history cache, so this is a client side thing. To me, the
only solution is to disable this caching for this page.

There some ways to do this as in;
http://www.4guysfromrolla.com/webtech/111500-1.shtml

Also try using the HttpCacheability
http://msdn.microsoft.com/library/de...lityofpage.asp

By the way, try using the Page.RegisterClientScriptBlock function instead of
directly writing with Response.Write, which has lots of advantages over it.
Take a look at this;

http://msdn.microsoft.com/library/de...ientsidesc.asp

I hope these will show you a way or give ideas.

Basarilar,

Ethem Azun

"Ersin Gençtürk" wrote:
hi,

I wrote a function like this :

public static void Alert(string message){
message=message.Replace("'","\'");

message=message.Replace("\n","\\n");

Response.Write("<script>alert('"+message+"');</script>");

}

this function is showing an alert box when necessary but when the user
navigate to another page and click back button of the browser then the last
error message shown again (as excepted because script is written top of the
page) but is there an event that I can capture if the user navigates to the
page first time ? and disable showing of the error ? ) I want a simple way I
solve this by using client time , server time etc.


Nov 18 '05 #2
You need to use RegisterStartupScript instead of response.write.
You olso need to write this only if IsPostback.

Excuse me for my bad english.
"Ersin Gençtürk" <ers[spam]@gencturk.org> ha scritto nel messaggio
news:ed**************@TK2MSFTNGP10.phx.gbl...
hi,

I wrote a function like this :

public static void Alert(string message){
message=message.Replace("'","\'");

message=message.Replace("\n","\\n");

Response.Write("<script>alert('"+message+"');</script>");

}

this function is showing an alert box when necessary but when the user
navigate to another page and click back button of the browser then the
last
error message shown again (as excepted because script is written top of
the
page) but is there an event that I can capture if the user navigates to
the
page first time ? and disable showing of the error ? ) I want a simple way
I
solve this by using client time , server time etc.


Nov 18 '05 #3
hi again , thnx for suggestions friends.

But the important part is not response.write here , because basically it has
no effect on this point.

My problem was about client side as Ethem said.It is a way to close cache
but , I need to load pages from browser cache , not again.So I can not send
browser a expires immediate like header.

One of the ways that I thought was while alerting to the user , giving that
alert a unique Id and storing it into a cookie , and in the jscript code ,
at first popup , setting a true cookie value , so when the user hits back
button of the browser , jscript code runs again in the client side , but it
will found that cookie value is setted to true before so it will not show
message box again.But I am searching for other ways (also not so
complicated ) to do it (of course this is an issue with client side jscript
code)

thnx again,selamlar


"Ersin Gençtürk" <ers[spam]@gencturk.org> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
hi,

I wrote a function like this :

public static void Alert(string message){
message=message.Replace("'","\'");

message=message.Replace("\n","\\n");

Response.Write("<script>alert('"+message+"');</script>");

}

this function is showing an alert box when necessary but when the user
navigate to another page and click back button of the browser then the last error message shown again (as excepted because script is written top of the page) but is there an event that I can capture if the user navigates to the page first time ? and disable showing of the error ? ) I want a simple way I solve this by using client time , server time etc.


Nov 18 '05 #4

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

Similar topics

2
by: Robert Nurse | last post by:
Hi All, I've got a strange problem in IE that I wonder if anyone has seen before. Basically, I've got a two window scenario. The parent window opens the child via window.open(). The child...
6
by: bonehead | last post by:
Greetings, I'm working on an e-mail form (btw many thanks to Philip Ronan for the very cool email address format tester function, best I've seen so far). I've been trying, with limited...
4
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
2
by: Kenneth | last post by:
Hi, In a document I have three lines that detects and redirects to another page is a session variable is 0 If Session("Customer_ID")=0 Then Response.Redirect("myPage.aspx") End If What I...
1
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
0
by: neeraj | last post by:
Hi Everybody I have one problem in my asp.net web application. The problem is that I check the date validation in code behind; if user not gives the valid data and press save button then I fire...
7
by: Jeff | last post by:
I am new to VB.net 2005 in visual web developer, and even newer to Javascript. I need a java alert box that contains text that eventually will come from an sql table. The alert box should...
4
by: ITCraze | last post by:
I am using alert, when user has successfully inserted the values in database. for ex: Response.Write("<script>alert("You have successfully inserted values");</script>"); This code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.