Cancel serverside event using client side event

C

csgraham74

Basically i have a piece of javascript that calls a function to call a
confirm box on screen.

onclick= if(sub_ProceedMsg()){}


basically what i want to do is to stop the serverside event from the
same button if i click no in my javascript confirm box.

is this possible ????


if not is there a better way to do this ???

i have to display a message on screen and get a response ( Yes or no )
from the user before i can proceed.

thanks in advance

C
 
C

Curt_C [MVP]

csgraham74 said:
Basically i have a piece of javascript that calls a function to call a
confirm box on screen.

onclick= if(sub_ProceedMsg()){}


basically what i want to do is to stop the serverside event from the
same button if i click no in my javascript confirm box.

is this possible ????


if not is there a better way to do this ???

i have to display a message on screen and get a response ( Yes or no )
from the user before i can proceed.

thanks in advance

C
nope....
The client wont even get the button till the process is already complete.
 
B

Bruce Barker

trival:

<input type=submit name=myButton onclick="return confirm('do
postback');">

you own client function just needs to return true or false.

note: to assign onclick event in codebehind (required for asp:buttons),
update the attributes collection.


-- bruce (sqlwork.com)
 
C

Curt_C [MVP]

That will stop it from starting, not cancel a server process once its
started.
 
S

Steve C. Orr [MVP, MCSD]

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 a more detailed analysis of your options, including a free control
that can handle many of the options for you.
http://SteveOrr.net/articles/ClientSideSuite.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top