alert box and problem with back button

E

Ersin Gençtürk

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

Guest

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/d...guide/html/cpconsettingcacheabilityofpage.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/d...-us/dnaspp/html/aspnet-injectclientsidesc.asp

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

Basarilar,

Ethem Azun
 
C

Cirrosi

You need to use RegisterStartupScript instead of response.write.
You olso need to write this only if IsPostback.

Excuse me for my bad english.
 
E

Ersin Gençtürk

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
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top