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

PopUp a confirmation message

I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a 'Success'
message and an OK button on it that returns the user to the form.

I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm
creating the <script language=javascript> block just fine. It contains a
function ShowConfirm(). How do I dynamically set the OnLoad attribute of
the <body> element to "javascript: ShowConfirm()" so that the confirmation
window displays after I do my processing in the OnClick event handler of my
button?

I'm using this code:

DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"

Is this the best way? Any suggestions?

Thanks,
Al
Nov 18 '05 #1
7 3083
On Tue, 15 Jun 2004 12:58:59 -0400, "Al Cadalzo" <ca*****@hotmail.com>
wrote:
I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a 'Success'
message and an OK button on it that returns the user to the form.

I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm
creating the <script language=javascript> block just fine. It contains a
function ShowConfirm(). How do I dynamically set the OnLoad attribute of
the <body> element to "javascript: ShowConfirm()" so that the confirmation
window displays after I do my processing in the OnClick event handler of my
button?

I'm using this code:

DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"

Is this the best way? Any suggestions?

Thanks,
Al


Just put a blank label at the bottom of your form. On success, set
the text property of the label to the script you want to run.

-Adam

Nov 18 '05 #2
Hi Al

Might I suggest that perhaps you are closer than you think?
RegisterStartupScript can be used all by itself to accomplish what you want.
You don't have to dynamically set the OnLoad attribute of the <body>
element. Remember that RegisterStartupScript not only can dynamically add
script to your page, but it can be used to immediately execute JavaScript
(i.e., instruct the client execute it immediately upon receipt). Try putting
the following code at the end of your server-side routine that updates your
database:

string scriptString = "<script language=JavaScript>ShowConfirm();</script>";

if(!this.IsClientScriptBlockRegistered("clientScri pt1")){
this.RegisterStartupScript("clientScript1", scriptString);
}

Note: I have not tested this code - rather I pulled some working code that
does something similar to what you need and modified it to include your
ShowConfirm() call. It might need to be tweaked...

-GH

"Al Cadalzo" <ca*****@hotmail.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a 'Success' message and an OK button on it that returns the user to the form.

I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm
creating the <script language=javascript> block just fine. It contains a
function ShowConfirm(). How do I dynamically set the OnLoad attribute of
the <body> element to "javascript: ShowConfirm()" so that the confirmation
window displays after I do my processing in the OnClick event handler of my button?

I'm using this code:

DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"

Is this the best way? Any suggestions?

Thanks,
Al

Nov 18 '05 #3
Al,

All you need to do is to put the javascript statement in the Http response:
Page.Response.Write("<script
language=\"Javascript\">ShowConfirm()</script>");

Eliyahu

"Al Cadalzo" <ca*****@hotmail.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a 'Success' message and an OK button on it that returns the user to the form.

I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm
creating the <script language=javascript> block just fine. It contains a
function ShowConfirm(). How do I dynamically set the OnLoad attribute of
the <body> element to "javascript: ShowConfirm()" so that the confirmation
window displays after I do my processing in the OnClick event handler of my button?

I'm using this code:

DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"

Is this the best way? Any suggestions?

Thanks,
Al

Nov 18 '05 #4
Eliyahu,

TFYR.

I could not get this technique to work.
When I view source I do not see this script. I step through the code so I
know that it is doing the Response.Write.

Thanks,
Al

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
Al,

All you need to do is to put the javascript statement in the Http response: Page.Response.Write("<script
language=\"Javascript\">ShowConfirm()</script>");

Eliyahu

"Al Cadalzo" <ca*****@hotmail.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a

'Success'
message and an OK button on it that returns the user to the form.

I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm creating the <script language=javascript> block just fine. It contains a function ShowConfirm(). How do I dynamically set the OnLoad attribute of the <body> element to "javascript: ShowConfirm()" so that the confirmation window displays after I do my processing in the OnClick event handler of

my
button?

I'm using this code:

DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"

Is this the best way? Any suggestions?

Thanks,
Al


Nov 18 '05 #5
Guadala,

TFYR. That worked great and it's nice because I can just create the
function in the .aspx and not in the code-behind.

Thanks,
Al
"Guadala Harry" <Ch*********@gh.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Hi Al

Might I suggest that perhaps you are closer than you think?
RegisterStartupScript can be used all by itself to accomplish what you want. You don't have to dynamically set the OnLoad attribute of the <body>
element. Remember that RegisterStartupScript not only can dynamically add
script to your page, but it can be used to immediately execute JavaScript
(i.e., instruct the client execute it immediately upon receipt). Try putting the following code at the end of your server-side routine that updates your database:

string scriptString = "<script language=JavaScript>ShowConfirm();</script>";
if(!this.IsClientScriptBlockRegistered("clientScri pt1")){
this.RegisterStartupScript("clientScript1", scriptString);
}

Note: I have not tested this code - rather I pulled some working code that
does something similar to what you need and modified it to include your
ShowConfirm() call. It might need to be tweaked...

-GH

"Al Cadalzo" <ca*****@hotmail.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a

'Success'
message and an OK button on it that returns the user to the form.

I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm creating the <script language=javascript> block just fine. It contains a function ShowConfirm(). How do I dynamically set the OnLoad attribute of the <body> element to "javascript: ShowConfirm()" so that the confirmation window displays after I do my processing in the OnClick event handler of

my
button?

I'm using this code:

DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"

Is this the best way? Any suggestions?

Thanks,
Al


Nov 18 '05 #6
Thanks Adam. Your method works just fine.

Al

<as******@inlandkwpp.com> wrote in message
news:ck********************************@4ax.com...
On Tue, 15 Jun 2004 12:58:59 -0400, "Al Cadalzo" <ca*****@hotmail.com>
wrote:
I want to respond to a submit button click on a form by writing to a
database then display a popup confirmation window that just has a 'Success'message and an OK button on it that returns the user to the form.

I've been playing with the RegisterStartupScript method to register my
javascript that opens a modal window that has the 'success' message. I'm
creating the <script language=javascript> block just fine. It contains a
function ShowConfirm(). How do I dynamically set the OnLoad attribute of
the <body> element to "javascript: ShowConfirm()" so that the confirmationwindow displays after I do my processing in the OnClick event handler of mybutton?

I'm using this code:

DirectCast(Me.FindControl("Body"),
HtmlContainerControl).Attributes("OnLoad") = "javascript:ShowConfirm()"

Is this the best way? Any suggestions?

Thanks,
Al


Just put a blank label at the bottom of your form. On success, set
the text property of the label to the script you want to run.

-Adam

Nov 18 '05 #7
On Wed, 16 Jun 2004 08:31:37 -0400, "Al Cadalzo" <ca*****@hotmail.com>
wrote:
Thanks Adam. Your method works just fine.

Al


Just as a note, you can set the property of the label and just set it
to visible when you want the javascript to run.

-Adam
Nov 18 '05 #8

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

Similar topics

2
by: Padam Jain | last post by:
i m populating some records by using DataGrid and i have put delete option as item template. now on click of delete i want to popup confirm message box. Please provide me solution. its very urgent...
0
by: Griff | last post by:
Hi, I have a button column placed on a datagrid at design time that is captioned "Delete". When the user clicks the button, I want to display a confirmation message, that they want to delete...
6
by: Dave | last post by:
Hello. I want to prompt user for some action with Yes/No message, I know some tricks in JavaScript, but I need to handle the user answer at server side. Exactly I want to prompt user for...
2
by: steggun | last post by:
How To: Popup Confirmation Dialog & Redirect in LinkButton_OnClick Hello All, I have a ASP.NET 2.0 (C#) web form with a LinkButton control. In the server-side code for the LinkButton_OnClick...
1
by: brianpmccullough | last post by:
I have an ASP.NET page that has a few buttons on it. One of the buttons kicks off a long running process on the web server and I want to prevent the user from clicking the button again while the...
1
by: beydtha | last post by:
Is there any code to get rid of such Popup block message ,,,,,,,,,,, that are shown at the time of openning a web site. would u plz help me to have such code ... ?
1
by: CutCopyPaste | last post by:
I need to close a window after unsuccessfull password attempts, the problem is the window has frames and is not opened using javascript. When trying to close the window confirmation message, i want...
5
by: nagendra138 | last post by:
how to display confirmation message for delete a record
4
by: John Straumann | last post by:
Hi all: I have an ASP.NET form that submits info to the server, but the customer wants a confirmation window to open when the user clicks "Submit", and then the user would have to click "OK" on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.