473,399 Members | 2,774 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,399 software developers and data experts.

How to popup a warning?

I have a "Delete" button on WebForm, but I want to popup a warning
message with OK and Cancel in case user clicked the button by accident.
HOW?

Nov 19 '05 #1
4 3474
Look at the Page.RegisterClientScriptBlock() method. This and javascript
should suit you well. The rest is a matter of logic and timing.

Dave
"Q. John Chen" <qj****@email.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a "Delete" button on WebForm, but I want to popup a warning
message with OK and Cancel in case user clicked the button by accident.
HOW?

Nov 19 '05 #2
Example:

<script type="text/javascript"><!--
function IsAccident() {
return (confirm("Is this an accident?");
}
// --></script>

<form ... onsubmit="return IsAccident()">

Explanation:

When an HTML form is submitted, the "onsubmit" event handler gives a "last
chance" to cancel the submit. It can call a JavaScript function that returns
true or false. If the function returns true, the form is submitted. If not,
the form is not submitted.

--
HTH,

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

"Q. John Chen" <qj****@email.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a "Delete" button on WebForm, but I want to popup a warning
message with OK and Cancel in case user clicked the button by accident.
HOW?

Nov 19 '05 #3
Thanks both for the quick response. I may put the question too simple.
My web form contains.

1. A "Search" button that retrieve data and fills the TextBoxes,
DropdownLists, and a DataGrid on the form.

2. An "Update" button to save the changes to the TextBoxes and
DropdownLists.

3. The DataGrid contains a Button Column ("Remove") on every row to
delete the datarow and all the Children (via FK cascading).

What I wanted is to popup warning when user click "Update" or the
"Remove".

I guess that putting code onsubmit will popup the warning even click on
the "Search" button.

I am thinking of UpdateButton.Attributes.Add("onclick", "return
confirm('Is this an accident?"); But wil this prevent form be
submitted. Also if doing popup on individual buttons, what about the
"Remove" buttons in the grid?

Thanks

John

1. I want a warnt

Nov 19 '05 #4
Here's some server side code that uses javascript to display a confirmation
message.

myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

Here's information about making this technique work with a datagrid:
http://www.dotnetjunkies.com/HowTo/1...EB07C94A8.dcik

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Q. John Chen" <qj****@email.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I have a "Delete" button on WebForm, but I want to popup a warning
message with OK and Cancel in case user clicked the button by accident.
HOW?

Nov 19 '05 #5

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

Similar topics

13
by: dave yan | last post by:
hi, i have some forms which use javascript for data validation, e.g., checking to make sure all required fields are completed, checking that data falls within valid ranges for certain fields,...
1
by: Person | last post by:
I have a popup window with a form: The popup window is opened like this: <SCRIPT LANGUAGE=javascript> window.open('primos.html', 'primos', config='height=300, width=400') </SCRIPT> The...
15
by: SJ | last post by:
I need to have some popups work for our company website but most popup blockers block popups pretty well. I was wondering if its possible to popup windows inspite of the popup blocker using...
7
by: Steve Jorgensen | last post by:
Hi all, Well, MS finally got the best of all worlds with the way the new message popup works in Outlook 2002. Does anyone know how a similar custom popup could be implemented from VBA, or if...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
2
by: sangram | last post by:
i need a javascript for popup window and how to pass value to that new window from old window .
5
by: perryche | last post by:
Is there a way to have a message popup ontop of all windows (not only in Access, but ontop of other windows) to give users a warning message? Does windows XP itself have anykind of instant...
9
by: Anic297 | last post by:
Hello, I'm a newbie in php. I would like to show a popup menu on my website and update the page when the user has changed its selection. I have looked over the Internet but haven't found what I...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.