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 |
![]() |
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 |
![]() |
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:
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:
Here is the problem: you need to add 'return' before conform. Try this: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);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 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 |
![]() |
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.)
![]() |
2 |
![]() |
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 |
![]() |