Popup Suggestion

C

C@rLoS

Dear All,

I wanna ask how I can make up some pop-up message in ASP.NET WebForm. I cant
find anything like MessageBox in ASP.NET, and I have tried to use Javascript
(alert) to make it. It works fine ONLY IF the page will NOT be redirected to
another page afterwards. When Response.Redirect(, FALSE) is launched (even I
place a "false" there to indicate I want to finish all the script before
redirecting), before the Javascript alert may have popped up, the page is
redirected and I cannot see any alert. Is there any solution for my case?
Thanks.

Carlos
 
E

Elton Wang

Hi Carlos,

You should understand that a web application is a client-
server mode, that is, your C# (or VB) code runs on server-
side, but javascript code runs on client-side. So when you
use alert(), it is in client-side. Unless after running
alert it posts back to server, it's impossible to run
Response.Redirect on server-side. Even if posts back to
server, you should also figure out it's after alert or on
other cases.

HTH

Elton Wang
(e-mail address removed)
 
K

Kevin Spencer

Might be a good time to explore other programming methods than Trial and
Error.

First, this isn't a Windows Form. There is no MessageBox. You are correct,
however, that the JavaScript alert() function would pop up a Message Box of
sorts (the browser equivalent). But you apparently don't have ny
understanding of Response.Redirect. Response.Redirect appends a header to
the Response, indicating that the browser should request a different URL.
You may have noticed that when you use Response.Redirect, you never see the
first page at all. That is because, rather than displaying it, the browser
redirects. Since JavaScript is IN the page, it is never executed.

Knowing this, of course, the answer is obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top