How to get the return value of Javascript Confirmation MessageBox in ASP.Net?
-
Hi all, I have been trying to use Javascript Confirmation Message Box in Asp.Net. However, I can not get the return value of this message box. I have tryed the method to add attributes at Page Load using the code like below: ******************** ibtnDelete.Attributes.Add("language", "javascript") ibtnDelete.Attributes.Add("OnClick", "return confirm('Are you sure you want to delete this record?');") This will bring up an OK/Cancel box when the button is clicked; if Cancel is then clicked the button's click event code won't run. ******************** But I want, firstly to run the click event of the button, and than according to some calculations give the user a message asking whether he / she wants to continue??, if the user says YES --> execute some code if NO --> execute nothing Is there a way to solve this problemm?? Thanks to everyone...
-
Hi all, I have been trying to use Javascript Confirmation Message Box in Asp.Net. However, I can not get the return value of this message box. I have tryed the method to add attributes at Page Load using the code like below: ******************** ibtnDelete.Attributes.Add("language", "javascript") ibtnDelete.Attributes.Add("OnClick", "return confirm('Are you sure you want to delete this record?');") This will bring up an OK/Cancel box when the button is clicked; if Cancel is then clicked the button's click event code won't run. ******************** But I want, firstly to run the click event of the button, and than according to some calculations give the user a message asking whether he / she wants to continue??, if the user says YES --> execute some code if NO --> execute nothing Is there a way to solve this problemm?? Thanks to everyone...
It's difficult mixing javascript confirmation with .cs code. The best bet for what you're trying to do is to use a modalpopupextender and then you have control over the buttons in your code.
-
It's difficult mixing javascript confirmation with .cs code. The best bet for what you're trying to do is to use a modalpopupextender and then you have control over the buttons in your code.
-
It's part of the ajaxtoolkit. I'm thinking it might even be better to use the ConfirmButton. Below is the url on how it all works. http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ConfirmButton/ConfirmButton.aspx