473,320 Members | 1,732 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,320 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 2966
> 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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.