display confirm message box for action

  • Thread starter Thread starter Grey
  • Start date Start date
G

Grey

how to design confirm message box, like Javascript Confirm box, in ASP.NET??
if the user click "YES" in the confirm box, i need to do something, else do
other things. Do I need to have javascript confirm box or ASP.NET has such
feature??


Million thanks.
 
how to design confirm message box, like Javascript Confirm box, in
ASP.NET??
if the user click "YES" in the confirm box, i need to do something, else
do
other things. Do I need to have javascript confirm box or ASP.NET has such
feature??

For client-side user interaction, use JavaScript.
 
for example:
create a button: button1
Page_Load():
this.Button1.Attributes.Add("onclick","javascript:if(confirm('No to
cancel?')== false) return false;");

if "Cancel" button pressed, this page will not post back.
 
Just to add to this.

You can ONLY cancel the post back with javascript like this, you cannot
branch and "do other things".

Greg
 
Handi said:
for example:
create a button: button1
Page_Load():
this.Button1.Attributes.Add("onclick","javascript:if(confirm('No to
cancel?')== false) return false;");

if "Cancel" button pressed, this page will not post back.

Just a note: don't change the javascript to the seemingly identical but shorter
return confirm('No to cancel?')
because .Net can add it's own javascript to that onclick handler. This shorter
version would prevent the execution of that code! This is also why you *need*
the closing ";" to separate your code from the additional code.

By the way, you don't need to specify "javascript:" for an onclick handler.

Hans Kesting
 
Back
Top