With ASP.NET, how do I prompt the user for a yes/no question and getting the result back to my .ascx?
So far I can open a confirmation dialog with use of Javascript, but I can't return the value. But I don't know if this is the right approach.
1) Form Design <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type = "text/javascript"> function Confirm() { var confirm_value = document. createElement("INPUT"); confirm_value. type = "hidden"; confirm_value.name = "confirm_value"; if (confirm("Do you want to save data?")) { confirm_value.
If you want to use ASP.NET Button:history. back(1); return false;" />
You can use standart JavaScript confirm()
function to show popup and do Post Back in case of Yes or No. For example:
if (confirm('Question')) {
__doPostBack('', 'Yes_clicked');
} else {
__doPostBack('', 'No_clicked')
}
Then on server in Page_Load()
method do:
if (IsPostBack)
{
var result = Request.Params["__EVENTARGUMENT"];
}
You can also do it async by specifying the first parameter of __doPostBack()
function as ID of any update panel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With