ASP Message Box

C

chuckdfoster

Hello Everyone,

I am trying to prompt the user for something. I don't think that I can use
a message box from ASP.NET. I have tried using VBScript to give the message
box, but I can't figure out how to do something with their response.
Example - They click a button. A message box pops up with OK and Cancel
buttons. If they click OK, then I need to redirect to another page. If
they click Cancel, then nothing needs to happen.

Any advice? Thanks in advance!
 
K

Kevin Spencer

We're talking about an HTML document here, don't forget.

JavaScript confirm() method - This is the one you need. It presents the user
with a message and an OK and Cancel button. If the user hits Cancel, it
returns false. If the user hits OK, it returns true.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
E

Eliyahu Goldin

javascript window.confirm (..) produces a message box with OL and Cancel
buttons. If it returns true, navigate away with window.navigate(..) or in
any other way. Everything on client side.

Eliyahu
 
C

chuckdfoster

Ok, So I lied. It isn't working quite like I want it to. I need to insert
data into a database if they answer OK. How can I use client-side
(window.confirm) and server-side (insert into db) together? I tried using
the Response.Write to send the JavaScript, but didn't get very far. Anymore
advice????

Thanks
 
S

Steve C. Orr [MVP, MCSD]

This server side VB.NET code outputs javascript to display a confirmation
message.

myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.
 
E

Eliyahu Goldin

Ok, this is something more then just redirecting to another page. On
pressing OK you need to postback to the same page. Just call
myForm.submit(). If you need to pass some extra info, you can use a hidden
<input> or any other standard way.

Eliyahu
 
C

chuckdfoster

Ok, that works great for a button. One more question. Can I add attributes
to a check box such as oncheckchanged? I have tried but can't get it to
work. I can get it to work for an "onclick" for a checkbox, but then can't
get any server side code to run.

Thanks for your help. Sorry for the trouble.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top