Monday, May 20, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
20
rated 0 times [  24] [ 4]  / answers: 1 / hits: 20192  / 13 Years ago, tue, may 3, 2011, 12:00:00

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.


More From » c#

 Answers
8

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.


[#92434] Sunday, May 1, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rocioblancac

Total Points: 699
Total Questions: 96
Total Answers: 108

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
;