PopUp Message aka Msgbox

Y

yop

All

Have searched the fields and hills for a good example but
alass not a sausage have I found, well not quite!

I understand that you cannot have a msgbox and have come
up with the solution to use Javascript on the Onclick
Event.

Code:

DeleteBtn.Attributes.Add("onClick", "javascript:return
confirm('Do you really want to?');")

Now this is fine, works and gives me an OK and CANCEL
option, problem is how do I get a return value?

Cannot seem to find an answer to this anywhere!

Thanks
 
R

Ravikanth[MVP]

Hi

Call a javascript function in onclick event of button.
Try this:

DeleteBtn.Attributes.Add
("onClick", "javascript:checkConfirm()")

<script language=javascript>
function checkConfirm()
{
var res = confirm('Do you really want to?');
//user res
}
</script>



Ravikanth[MVP]
 
S

S. Justin Gengo

yop,

Try this out:

WebControlButton.Attributes.Add("onClick", "javascript:if(!confirm('" &
MessageToDisplay & "')) return false;")

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Y

yop

A stupid question but if I was to add that CheckConfirm
code into a vb file how would it work?
Apologise about this.

Or if I leave it in the HTML how do I grab the result
from inside in the VB file?
 
K

Kevin Spencer

You are already getting a return value. Your script says so. It says "return
confirm('Do you really want to?')". This cancels any submit that might
happen. What else would you like to do with the return value from the
JavaScript confirm() function?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.
 
Y

yop

The click even of the button is still happening
regardless of wheather or not the user is clicking Yes or
No? must be leaving something out somewhere
 
S

S. Justin Gengo

Yop,

If you try out the code I posted you'll see that the button click never
fires client side if you click cancel.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Y

yop

Apologies S Justin! I took the first solution that was
there. It works spot on, I am sure that the other one
works as well, just did not seem to do it for me!!

Thanks all much appreicated
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top