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

Javascript confirmation boxes..

Hi People,

Wondering how we display confirmation boxes to the user in order to confirm
his action, before we can proceed. How do we get back the value from the
user's action, i.e. if he selects yes, or he selected no, in to our code in
c#.net, so we can take the appropriate action. I'm not very clear on
javascript interaction with asp.net.

Hope you guys can help,

Thanks,

I.A
Nov 19 '05 #1
4 2968
> Wondering how we display confirmation boxes to the user in order to
confirm his action, before we can proceed. How do we get back the
value from the user's action, i.e. if he selects yes, or he selected
no, in to our code in c#.net, so we can take the appropriate action.
I'm not very clear on javascript interaction with asp.net.


Generally this is done like so:

<asp:button id="..." runat="server" text="..." onclick="return confirm('Are
you sure you want to do this?');" />

Where if false is returned from the onclick handler, the postback will not
occur. If you want to know if they select no, you'll need to wrap the confirm
in something that will return the value, something like:

<input type="hidden" runat="server" id="confirmResult" />
<asp:button ... onclick="document.getElementById('confirmResult'). value =
confirm('Are you sure you want to do this?);" />

Then check for confirm result in the click handler for the button.

Hth, Rya
Nov 19 '05 #2
> Wondering how we display confirmation boxes to the user in order to
confirm his action, before we can proceed. How do we get back the
value from the user's action, i.e. if he selects yes, or he selected
no, in to our code in c#.net, so we can take the appropriate action.
I'm not very clear on javascript interaction with asp.net.


Generally this is done like so:

<asp:button id="..." runat="server" text="..." onclick="return confirm('Are
you sure you want to do this?');" />

Where if false is returned from the onclick handler, the postback will not
occur. If you want to know if they select no, you'll need to wrap the confirm
in something that will return the value, something like:

<input type="hidden" runat="server" id="confirmResult" />
<asp:button ... onclick="document.getElementById('confirmResult'). value =
confirm('Are you sure you want to do this?);" />

Then check for confirm result in the click handler for the button.

Hth, Rya
Nov 19 '05 #3
couple notes:

1) onclick for a asp:button is the server click, so you need to use the code
behind and add an attribute to do the client clcik,
2) some versions of IE 6.0 have bug where "return false", does not cancel
the postback. you need to cancel in the event

if (document.all && window.event ) event.returnValue = false; return
false;

-- bruce (sqlwork.com)

"Ryan Trudelle-Schwarz" <ne**@mamanze.com> wrote in message
news:45**************************@news.microsoft.c om...
| > Wondering how we display confirmation boxes to the user in order to
| > confirm his action, before we can proceed. How do we get back the
| > value from the user's action, i.e. if he selects yes, or he selected
| > no, in to our code in c#.net, so we can take the appropriate action.
| > I'm not very clear on javascript interaction with asp.net.
|
| Generally this is done like so:
|
| <asp:button id="..." runat="server" text="..." onclick="return
confirm('Are
| you sure you want to do this?');" />
|
| Where if false is returned from the onclick handler, the postback will not
| occur. If you want to know if they select no, you'll need to wrap the
confirm
| in something that will return the value, something like:
|
| <input type="hidden" runat="server" id="confirmResult" />
| <asp:button ... onclick="document.getElementById('confirmResult'). value =
| confirm('Are you sure you want to do this?);" />
|
| Then check for confirm result in the click handler for the button.
|
| Hth, Ryan
|
|
Nov 19 '05 #4
couple notes:

1) onclick for a asp:button is the server click, so you need to use the code
behind and add an attribute to do the client clcik,
2) some versions of IE 6.0 have bug where "return false", does not cancel
the postback. you need to cancel in the event

if (document.all && window.event ) event.returnValue = false; return
false;

-- bruce (sqlwork.com)

"Ryan Trudelle-Schwarz" <ne**@mamanze.com> wrote in message
news:45**************************@news.microsoft.c om...
| > Wondering how we display confirmation boxes to the user in order to
| > confirm his action, before we can proceed. How do we get back the
| > value from the user's action, i.e. if he selects yes, or he selected
| > no, in to our code in c#.net, so we can take the appropriate action.
| > I'm not very clear on javascript interaction with asp.net.
|
| Generally this is done like so:
|
| <asp:button id="..." runat="server" text="..." onclick="return
confirm('Are
| you sure you want to do this?');" />
|
| Where if false is returned from the onclick handler, the postback will not
| occur. If you want to know if they select no, you'll need to wrap the
confirm
| in something that will return the value, something like:
|
| <input type="hidden" runat="server" id="confirmResult" />
| <asp:button ... onclick="document.getElementById('confirmResult'). value =
| confirm('Are you sure you want to do this?);" />
|
| Then check for confirm result in the click handler for the button.
|
| Hth, Ryan
|
|
Nov 19 '05 #5

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

Similar topics

0
by: frasfan | last post by:
Hi, I am having a problem with the validator controls in VB.net conflicting with the javascript I am using to confirm whether or not the user wants to submit the page. Here is the situation: I...
4
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
8
by: Brent_White_99 | last post by:
I copied the code from another HTML script that someone before me had written. I have no Javascript experience (I'm a VB Programmer/DBA) at all. The code below works to a certain extent. There...
7
by: Irfan Akram | last post by:
Hi People, I have got a simple question to ask. I am trying to build dynamic controls in asp.net. I have managed to build them successfully. I have also managed to add the event handlers to all...
0
by: Irfan Akram | last post by:
Hi People, Wondering how we display confirmation boxes to the user in order to confirm his action, before we can proceed. How do we get back the value from the user's action, i.e. if he selects...
2
by: bienwell | last post by:
Hi all, I still have a problem when using Confirmation box in ASP.NET program. I need to get the value return of YES or NO from confirmation box in Sub function of VB program to do some tasks....
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
2
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the...
4
by: =?Utf-8?B?c3Jpbml2YXM=?= | last post by:
Hi, I'm having an ASP.net page with a dropdown list box named ddlStatus, a button and editable gridview. I wrote a small javascript function "OnSave()" and called it on the event...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.