display confirm message box for action

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.
 
M

Mark Rae

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.
 
G

Guest

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.
 
G

Greg Burns

Just to add to this.

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

Greg
 
H

Hans Kesting

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top