ASP Message Box

  • Thread starter Thread starter chuckdfoster
  • Start date Start date
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!
 
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.
 
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
 
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
 
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.
 
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
 
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.
 
Back
Top