473,387 Members | 1,515 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,387 software developers and data experts.

Confirming postback from javascript ALERT?

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
Apr 25 '06 #1
3 2613
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.

"Darrel" <no*****@nospam.com> wrote in message
news:OH**************@TK2MSFTNGP05.phx.gbl...
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

Apr 25 '06 #2
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
Apr 25 '06 #3
Hi,

Darrel wrote:
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


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/myjavascri...000090401.html

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

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Apr 26 '06 #4

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

Similar topics

6
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...
7
by: Michel | last post by:
Hi all, Is there some intelligent way to trigger a clientside JavaScript function before a postback is triggerd by any of the controls on a page? Thanks in advance, Michel Mathijssen
3
by: Charlie | last post by:
Hi: when the user selects the save button (asp control) to intiate a postback, I would like to pop up a javascript alert box to confirm if he really wants to save. If he selects no from alert...
4
by: Jeremy | last post by:
I have an ASPX page with a bunch of System.Web.UI.WebControls.Button controls on it. By default, clicking on any of these causes a Postback. I'd like to have it so that for a couple of these...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
21
by: Martin Eyles | last post by:
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object expected". I think this is because the page's script...
3
by: James Thomas | last post by:
I have an issue with the login process on my site since the upgrade to ASP .NET 2.0 (from 1.1). I have the standard textbox and button for logging and my own custom login process. I'd like to...
9
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
I have what seems to be a relatively simple problem when attempting to simulate a postback in ASP.NET from JavaScript. My scenario is (and please don't ask me why) that I have an HTML <a>nchor...
3
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.