473,701 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5009

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 HttpCacheabilit y
http://msdn.microsoft.com/library/de...lityofpage.asp

By the way, try using the Page.RegisterCl ientScriptBlock 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 RegisterStartup Script 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******** ******@TK2MSFTN GP10.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******** ******@TK2MSFTN GP10.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
2301
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 contains a form and submissions are processed in the child window. When the child window form is submitted and the results are returned, an alert box is thrown up via setTimeout("alert(....)", 2000). For some odd reason, when this alert is...
6
3137
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 success, to produce a javascript alert box which shows the user a validation error message. The error message itself is dynamic, i.e., it's contained within a php variable. I seem to be running into two issues:
4
29914
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 button, validating data and then wanting to simply pop-up an alert if say the login is empty. When I click the button though the page is blank but the pop-up is there.
2
2881
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 really would like to have is a notification for the
1
1668
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 button, validating data and then wanting to simply pop-up an alert if say the login is empty. When I click the button though the page is blank but the pop-up is there.
0
1970
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 my own exception by JavaScript alert message Through register startup script Like RegisterStartupScript("Startup", "<script language=javascript>
7
2269
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 activate when the user clicks on text or a button (or something similar). The test code below will do most of what I need (I didn't include the code to retrive from the table for simplicity). Since I don't know much java, I'm attempting to do as much...
4
1337
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 successfully runs, but the problem is that when I press the back button in my application from any page , this alert box also appears. I don't want alert window to appear when clicking on Back button.
0
8736
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8649
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9229
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9083
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4410
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3102
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2398
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.