PopUp Message aka Msgbox

  • Thread starter Thread starter yop
  • Start date Start date
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
 
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]
 
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
 
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?
 
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.
 
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
 
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
 
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
 
Back
Top