Confirming postback from javascript ALERT?

D

Darrel

I have a page that lists a bunch of items. You can check each item and hit
ADD to add these items to a record in the DB.

This page has a dropDownList. When you select an item from the list, I want
to do an auto-postback and then list a new bunch of items that you can,
again, check and click on ADD.

If a person has items checked, and then changes the DDL BEFORE cliccking on
ADD, I want to pop-up a confirmation 'do you want to add these items before
changing groups?'

Ideally, it'd say YES | NO | CANCEL

I realize CANCEL may not work.

That said, I can still do the YES | NO confirmation javascript alert? If so,
how does that interact with the auto-postback javascript?

-Darrel
 
K

Kevin Spencer

You can use the JavaScript confirm method to create an alert box with on OK
and Cancel button on it. The method returns true if the OK button was
clicked, and false otherwise. You can use this with a client-side event
handler to either allow the event or disallow it.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
D

Darrel

You can use the JavaScript confirm method to create an alert box with on
OK
and Cancel button on it. The method returns true if the OK button was
clicked, and false otherwise. You can use this with a client-side event
handler to either allow the event or disallow it.

So, sounds like I should just co-opt the autopostback javascript, modify to
add the alert, and then attach that manually (register it) to the DLL.

Thanks!

-Darrel
 
L

Laurent Bugnion

Hi,
So, sounds like I should just co-opt the autopostback javascript, modify to
add the alert, and then attach that manually (register it) to the DLL.

Thanks!

-Darrel

I would use alert, confirm and the likes with care. They were actually
developed at a time where not debugger was available for client-side
JavaScript, to help developers to debug their code. Their main
disadvantage is that they usually (but not in every browser
consistently) block the execution of the JavaScript code. If an alert is
displayed, no JavaScript can be executed, thus no web method can be
called, for example. This can be a killer in some cases.

As an example, we have a web application which uses web services to
lease licenses from the server. When the license expires, another user
can lease it and work wth the application. Thus, it's very important
that the lease s renewed periodically, or else the user might lose the
license and its privileges. For this reason, we forbid our developers to
use alert or other blocking dialogs.

Additionally, another disadvantage of these dialogs is that they look
ugly, cannot be styled, and look different in each browser. It's way
better (and doesn't cost much time) to develop your own, preferably
using a floating DIV, or if you can't, using a pop-up.

I have a (very old) example of an alert box using a pop-up here:
http://www.galasoft-lb.ch/myjavascript/consulting/2000090401.html

Not state of the art anymore, but it works. Today I would implement that
differently.

HTH,
Laurent
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top