Is there an elegant way that I can return a value from a JavaScript function
to ASP.NET? I want to have a popup confirmation dialog using JavaScript and
only have a button control execute its ASP code if the confirmation is
positive. I can associate the JavaScript with the button using the Attributes
property and get the confirmation dialog to appear but the button control
always executes. 4 8521
something like:
myButton.Add("o nclick","return confirm('Are you sure you wish to do
this?');");
MattC
"phil" <ph**@discussio ns.microsoft.co m> wrote in message
news:9C******** *************** ***********@mic rosoft.com... Is there an elegant way that I can return a value from a JavaScript function to ASP.NET? I want to have a popup confirmation dialog using JavaScript and only have a button control execute its ASP code if the confirmation is positive. I can associate the JavaScript with the button using the Attributes property and get the confirmation dialog to appear but the button control always executes.
MattC wrote: something like:
myButton.Add("o nclick","return confirm('Are you sure you wish to do this?');");
MattC
It's better to use "if (!confirm('Are you sure?')) return false;"
(don't forget the last ";" !)
especially for imagebuttons and linkbuttons, because asp.net will
add it's own functions to that same onclick, and you *do* want
those to execute when the question is confirmed. "phil" <ph**@discussio ns.microsoft.co m> wrote in message news:9C******** *************** ***********@mic rosoft.com...
Is there an elegant way that I can return a value from a JavaScript function to ASP.NET? I want to have a popup confirmation dialog using JavaScript and only have a button control execute its ASP code if the confirmation is positive. I can associate the JavaScript with the button using the Attributes property and get the confirmation dialog to appear but the button control always executes.
--
Hans Kesting
I can see that the JavaScript is returning a value but how do I consume it
from within some C# code behind? Suppose I have a C# click event handler that
executes a stored procedure and the same button has this JavaScript confirm
assigned to it via mybutton.Attrib utes.Add. The C# code seems to execute
after the JavaScript regardless of the script return value. I can't see how
to test the JavaScript return value in order to prevent the C# code from
executing or call a different C# method upon a true return value.
"Hans Kesting" wrote: MattC wrote: something like:
myButton.Add("o nclick","return confirm('Are you sure you wish to do this?');");
MattC
It's better to use "if (!confirm('Are you sure?')) return false;" (don't forget the last ";" !) especially for imagebuttons and linkbuttons, because asp.net will add it's own functions to that same onclick, and you *do* want those to execute when the question is confirmed.
"phil" <ph**@discussio ns.microsoft.co m> wrote in message news:9C******** *************** ***********@mic rosoft.com...
Is there an elegant way that I can return a value from a JavaScript function to ASP.NET? I want to have a popup confirmation dialog using JavaScript and only have a button control execute its ASP code if the confirmation is positive. I can associate the JavaScript with the button using the Attributes property and get the confirmation dialog to appear but the button control always executes.
-- Hans Kesting
Sorry, this does work as suggested. However, I'd really like to understand
why the C# code doesn't execute (which is the right behaviour) upon a
returned false value. What mechanism handles the returned script value?
"Hans Kesting" wrote: MattC wrote: something like:
myButton.Add("o nclick","return confirm('Are you sure you wish to do this?');");
MattC
It's better to use "if (!confirm('Are you sure?')) return false;" (don't forget the last ";" !) especially for imagebuttons and linkbuttons, because asp.net will add it's own functions to that same onclick, and you *do* want those to execute when the question is confirmed.
"phil" <ph**@discussio ns.microsoft.co m> wrote in message news:9C******** *************** ***********@mic rosoft.com...
Is there an elegant way that I can return a value from a JavaScript function to ASP.NET? I want to have a popup confirmation dialog using JavaScript and only have a button control execute its ASP code if the confirmation is positive. I can associate the JavaScript with the button using the Attributes property and get the confirmation dialog to appear but the button control always executes.
-- Hans Kesting This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Darren Dale |
last post by:
Hello,
def test(data):
i = ? This is the line I have trouble with
if i==1: return data
else: return data
a,b,c,d = test()
|
by: Terry A. Haimann |
last post by:
I have been working on creating a dynamic web page and have made slow but
steady progress. What I have now has an opening page with two drop
down boxes. Based on a choice from the first box, the second box is
populated from a mysql table. The values from two boxes are then sent via
a query string to a new page. The 2nd page then uses these two values and
runs a select against the mysql database and creates an html table.
This all runs...
|
by: Sue |
last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided
to improve character checking on my project. In my project I only had
to do very basic validation. Therefore, I only had one function to
verify the name fields, age, email and gender.
My question is: if I create a function for each field like the code
below, what would be the best way to organize the functions and call
them? Would I need one main function and place...
|
by: phil |
last post by:
Is there an elegant way that I can return a value from a JavaScript function
to ASP.NET? I want to have a popup confirmation dialog using JavaScript and
only have a button control execute its ASP code if the confirmation is
positive. I can associate the JavaScript with the button using the Attributes
property and get the confirmation dialog to appear but the button control
always executes.
|
by: Dr John Stockton |
last post by:
I'm starting a new thread, for clarity.
I'm assuming that it's ECMA-262 3rd Edn (1999) that we should be using
for Web pages; that 4th Edn (what's its present status? is it
available?) is too advanced for compatibility with many browsers in
present-day use; that Web authors should be aware of what JScript and
..NET may do, but cannot rely on it; and that MS documents describe the
latest MS code as distinct from agreed standards.
| |
by: Rene Nyffenegger |
last post by:
Hello everyone.
I am not fluent in JavaScript, so I might overlook the obvious.
But in all other programming languages that I know and that
have associative arrays, or hashes, the elements in the
hash are alphabetically sorted if the key happens to
be alpha numeric. Which I believe makes sense because
it allows for fast lookup of a key.
|
by: Dan Rumney |
last post by:
Hi all,
I've been writing Javascript for quite a while now and have, of late,
been writing quite a lot of AJAX and AJAX-related code.
In the main, my dynamically generated pages are created using Perl on
the backend, with Javascript providing limited frontend functionality.
As an example, an expanding tree would be fully populated on the
server-side and then presented to the browser, with Javascript and CSS
being used to vary the...
|
by: James Kimble |
last post by:
Yeah I'm sure this is a stupid question.
I've got a javascript source file with functions (creates a bar graph)
I want to call from inside an html table cell so that the graph
appears in the cell. I've tried a bunch of different things but I'm
not getting it. I'm a newbee to both html and javascript so be kind.
Any example would be appreciated.
|
by: shapper |
last post by:
Hello,
How to create a namespace in Javascript containing two methods?
And how to access those methods?
Thanks,
Miguel
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |