Cancel response from confirm message box is not working.


Hello,

I have this ScriptManager class below for the confirm message box along with the function calls from the server side for the "Ok" response.  If the response is Ok from the confirm message box, it will goes on in the code and call one of the function from the server side "PerformSearch()" and if the response is Cancel, don't do anything and close out the confirm message box.  When I click the "Cancel" button on the confirm box, it still goes on and perform a function from the server side  just like the "Ok" response, how do I avoid the "Cancel" response to continuing on executing the code?

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "confirm('Unable to locate your search item. Do you want to search the closest match from your item?\.');", true);

PerformSearch()

-1
boston_ma
12/22/2008 8:41:58 PM
asp.net.getting-started 91979 articles. 2 followers. Follow

6 Replies
2505 Views

Similar Articles

[PageSpeed] 13

You usually need to return the value from the "confirm()" call since confirm returns a boolean value.

Why not use the ASP.NET AJAX ConfirmButton?


Darrell Norton, MVP
Darrell Norton's Blog


Please mark this post as answered if it helped you!
-1
DarrellNorton
12/22/2008 9:05:41 PM

Thanks DarrellNorton for replying,

do you have the sample code by any chance for the return value from the "confirm()" call ? 

 I try to use the sample in ASP.NET AJAX Confirmation but gets an error for unknow server tag "ajaxToolkit:ConfirmButtonExtender ", I'm using VS2005 and AJAX toolkit 2.0.

 

-1
boston_ma
12/23/2008 2:56:46 AM

boston_ma:

Thanks DarrellNorton for replying,

do you have the sample code by any chance for the return value from the "confirm()" call ? 

I try to use the sample in ASP.NET AJAX Confirmation but gets an error for unknow server tag "ajaxToolkit:ConfirmButtonExtender ", I'm using VS2005 and AJAX toolkit 2.0.

Hi Boston,

Let's back to the original issue: 

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "confirm('Unable to locate your search item. Do you want to search the closest match from your item?\.');", true);
Here is the problem: you need to add 'return' before conform. Try this: 
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "return confirm('confirm?\.');", true);

Best Regards,
Shengqing Yang


Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread : )
-1
Shengqing
12/24/2008 6:48:54 AM
Shengqing Yang - MSFT:

you need to add 'return' before conform. Try this: 

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "return confirm('confirm?\.');", true);

Thanks Shengqing Yang for replying,

I tried your code and got an error "Unrecognized escape sequence" where the dot (.) is after the backslash.  I removed the backslash and the confirm message box did not pop up but it did continue on executing the code after the 'ScriptManager.....'  and display out to the form. 

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", " return confirm('confirm?.');", true);

If I don't add "return" code before the confirm, it shows the confirm box but the "Cancel" response works just like the "Ok" response.  I set the debugger where the ScriptManager code and it shows that it executes all the code after the ScriptManger before it displays the message box and if I click the "Ok" button on the confirm box, the second breakpoint after the ScriptManager code didn't hit. Why is it?  Is there a way to catch the 'Ok' or 'Cancel' event fire from the message box?

1
boston_ma
12/24/2008 6:50:08 PM

 If you could show more of your code, it would help quite a bit more, but try this...

 

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "if (confirm('Unable to locate your search item. Do you want to search the closest match from your item?\.')) PerformSearch();", true);

 

And remove the PerformSearch() call from the start of the page markup (I'm assuming that's where it is.)

1
pramsperger
12/24/2008 10:30:41 PM

 Hello,

See the below link.

 

http://aspdotnetdevs.blogspot.com/2008/12/making-server-side-decision-based-on.html

 

I hope this will help you.


Thanks & Regards
Sandeep Reddy Pasham
GGK Technologies, Hyd
www.ggktech.com
http://aspdotnetdevs.blogspot.com
~ Please remember to click Mark as Answer on this post if it helped you ~
-1
sandeepreddi
12/25/2008 9:15:42 AM
Reply:

Similar Artilces:

superreview cancelled: [Bug 127461] Get New Messages stops working for one account : [Attachment 157755] Proposed patch
Christian Eyrich <ch.ey@gmx.net> has cancelled David Bienvenu <bienvenu@nventure.com>'s request for superreview: Bug 127461: Get New Messages stops working for one account http://bugzilla.mozilla.org/show_bug.cgi?id=127461 Attachment 157755: Proposed patch - Implements a pop3 response timer to drop hung connections http://bugzilla.mozilla.org/attachment.cgi?id=157755&action=edit ...

Get message that mozilla has to close. Get booted out of web site. Get message from Mozilla to report problem. Problem reporting will not work. Eventually I delete the report message.
Name: Linnea Hagberg Email: lhagbergatsmithcovedotcom Product: Mozilla Suite Summary: Get message that mozilla has to close. Get booted out of web site. Get message from Mozilla to report problem. Problem reporting will not work. Eventually I delete the report message. Comments: See above. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7 ...

Confirm message box not working
Hi, i use fileupload control for upload image.so when i design fileupload control with in update panel and add the a trigger like following within it then my confirm message box is not working. if someone face the problem please help me. my trigger is like it is just below <Triggers> <asp:PostBackTrigger ControlID="BTNSUBMIT" /> </Triggers> my message syntax are  ScriptManager.RegisterStartupScript(Me, GetType(Page), UniqueID, "alert('Record Inserted Sucessfully')", True)  and  ClientScript.RegisterStartupSc...

How do you get the response from message box?
Hello, I have a confirm message box that displays "yes" or "no", If a user clicks "yes", do something, but for some reasons I can't get the message response from the message box in the code behind.  Can anyone shows me how to get the response from the message box?  Thanks  Here is the code that display the confirm message box: btnClick.Attributes.Add("onclick", "return confirm('Are you sure you proceed?');");  You can use below. If yes is clicked it will go further.btnClick.Attributes.Add("onclic...

How to get the response from this javascript confirm message
How to get the response value ie true or false when click the yes in confirm box. ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "return confirm('Do you want to continue');", false);  note: Not using "attribute.add" because if use this once javascript is bind to the browser it will show the confirm box when not choose the check box for delete.  please give me the solution as soon as possible confirm returns a true if clicked is yes and false if no.. put an if statement to it.. if(confirm()) { clicked yes ...

Capturing the response from a confirm message box
I created a confirm message box using:private void MessageBox2(string msg) {Label lbl2 = new Label();lbl2.Text = "<script language='javascript'>" + Environment.NewLine + "window.confirm('" + msg + "')</script>"; Page.Controls.Add(lbl2); } and then call it later with: MessageBox2("Testing Confirm Function");   The problem is, I have no way of determining what the client has selected Ok or Cancel. I need to be able to test that click inorder to determine if the record to the database will be updated. Any suggesti...

Button with Confirmation Message
Guys,  I am trying a small example of adding comfirmation message to a button and want to abort Postback if user clicks  cancel on confirmation. Following is my code .. Postback happens even I click 'Cancel' . I am missing something here ..please help ..   <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd...

How to get the return value from confirm message box?
In this case, I have a radiobuttonlist control, if the user changed the radiobuttonlist's index, then the application will be prompted a confirm message box. If use click the "OK", then proceed, otherwise, remain unchanged. I tried to write the code under the event (radiobuttonlist_SelectedIndexChanged): radiobuttonlist_SelectedIndexChanged (Byval sender as object, Byval e as Eventargs) response.write("<script lang=javascript>confirm('Confirm to proceed!')</script>") textbox1.visible = True However, no matter what the user chosen, the t...

Confirmation Message Box with Replace and Cancel buttons
Hi,   I would like to seek help on how to create a confirmation message with Replace and Cancel buttons.  And also, how can I check if user clicked the Replace button.    Thanks.   Hi, You can create your own Cofirmation msg dialog. u require, div tag, with 2 buttons and text to display. Make this div to display(visible) when u want and allow to user to click any of the button. if clicked 'cancel' set to 'return false;' if clicked 'replace' call respective function() with ur required code in it or set a global var. with value...

Problem dealing with the confirm message box in C#.net
Hi..i am actually trying to do something like this.When a user select a particular option from a dropdown list and click a 'Go' button, a confirm message box will be displayed if the user has selected that particular option.Other options selected will not display that confirm box when the 'Go' button is clicked.Once the user press the ok button on the confirm box,it will proceed to perform other tasks.How do i do that?..I try using the following code but it doesnt really work..the confirm box will always popup everytime the 'Go' button is clicked except for the first time u clicked on it. ...

Confirm Message Box with OK or Cancel option in C#
Hi  All, I have a function call which  results in two conditions(True and False).When the condition is false,I wanted the code to display a message box with the two options (OK and Cancel) and when the user clicks the OK button It should direct to another page. Please anyone help me with the code ( in C# ) to display a confirm message box with this two options.Its urgent. Thanks for your help.     private void button3_Click(object sender, System.EventArgs e) { if (MessageBox.Show("Really delete?","Confirm delete", MessageBoxButto...

How to get return from confirm message box when text change event
 hi all,i need to use confim message box to get response when the text change event.and i need to use that response in code behind.please send me answer qiuck.thanks See the example in this link : http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.interaction.msgbox(VS.80).aspx   You can do something like this  Dim msg As String Dim title As String Dim style As MsgBoxStyle Dim response As MsgBoxResult msg = "Do you want to continue?" ' Define message. style = MsgBoxStyle.DefaultButton2 Or _ MsgBoxStyle.Critical Or MsgBoxStyle.YesNo ...

How to set focus to "Cancel" button in the confirm message box?
Hi, I am using the following code to pop up a confirmation box: btnDelete.Attributes.Add("onclick", "if (confirm('Are you sure you want to delete this item?')){}else{return false}"); Could anyone let me know if there is a way to set the default focus to the "Cancel" button instead of the "OK" button? Thanks can't be done. sorry....

"Offline->Get seleted messages" not working? Confirmation needed
Or at least that's what I think! So before posting to bugzilla I need a sanity check: I presume that "Offline->Get selected messages" menu option *should* download a selected message, and store it for offline viewing. When reading the usenet recently, this feature (which I'm sure I've used before) doesn't seem to work! Hope someone can help -Rob. Robert North wrote: > Or at least that's what I think! > > So before posting to bugzilla I need a sanity check: > I presume that "Offline->Get selected messages" menu optio...

Web resources about - Cancel response from confirm message box is not working. - asp.net.getting-started

America's Response Monument - Wikipedia, the free encyclopedia
dedicated to the United States Special Forces and commemorates the servicemen and women of America’s Special Operations response to 9/11, including ...

Police response to wild brawl outside Carlton's Illusion nightclub criticised
... Carlton nightclub on Sunday morning, but the promoter of the Christmas function for Melbourne's African community has slammed the police response ...


Miss Colombia had an incredibly graceful response after being mistakenly crowned Miss Universe
If a pageant queen is measured for her grace under pressure, then Miss Colombia is still a winner. On Sunday night, Miss Colombia Ariadna Gutierrez ...

Two Fatally Shot By Chicago Police In Response To Domestic Disturbance On West Side
Police were called to an apartment building on the 4700 block of West Erie at about 4:30 a.m. Saturday for a domestic incident.

Fitness instructor in Ohio offers active shooter response training
Amid heightened fears of terrorism and mass shootings, the course is one of many offered across the country

The Correct Response To Holiday Attire
Submitted by: (via nessy1 ) Tagged: christmas , tie , no , Cats Share on Facebook

Kurt Russell's Blunt Response To The Guardians Of The Galaxy 2 Casting Rumors
Last week, it was reported that Kurt Russell is being considered by Marvel to play Peter Quill’s father in Guardians of the Galaxy Vol. 2 . Here’s ...

Home Alone's Daniel Stern Has Hilarious In Character Response To Macaulay Culkin
Earlier this month, Macaulay Culkin set the Internet on fire by releasing a video where he played [...]

NHL Star Delivers Awesome Response After Losing Teeth
NHL Star Delivers Awesome Response After Losing Teeth

Resources last updated: 12/29/2015 8:16:44 AM