Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msgbox in asp

Status
Not open for further replies.

frogggg

Programmer
Jan 17, 2002
182
US
How do I do the equivalent of a Yes/No msgbox in vbScript.asp? I'm getting a permission denied error, and I looked in the documentation and it said it was removed from vbScript in asp.
Does anyone know how I can get around this problem?
Tbank you.
 
you cannot create msgbox's with server-side code, this must be done as client-side code.

in your HTML, you could do the following with the javascript confirm() function:

Code:
<input type=&quot;button&quot; name=&quot;myButton&quot; value=&quot;ThinkBeforeClicking!&quot;
onClick=&quot;return confirm('Are you sure???');&quot;>

this presents the OK/Cancel dialog, which returns TRUE if OK, FALSE if CANCEL. (i think on a mac it is actually YES and NO, but same thing)

good luck!

 
Thanks!
How would I do this as inline code in a serverside event handler?
<script ID=&quot;serverEventHandlersVBS&quot; LANGUAGE=&quot;vbscript&quot; RUNAT=&quot;Server&quot;>
Sub btnDeletePost_onclick()
dim msgString
msgString = &quot;Are you sure you want to delete &quot; & rsEmpPosts.fields.getValue(&quot;JobTitle&quot;) & &quot;?&quot;
msgString = msgString & &quot;All the skills relating to this post will also be deleted.&quot;
' MsgBox msgString, 260, &quot;Delete Record&quot;
'if they say yes then delete if they say no, return to page
rsEmpPosts.deleteRecord

'get related skills
rsPostSkills.setSQLText(&quot;SELECT JobSkills.* &quot; _
& &quot;FROM JobSkills &quot; _
& &quot;WHERE JobSkills.ReferrenceNum =&quot; & rsEmpPosts.fields.getValue(&quot;ReferenceNum&quot;))
rsPostSkills.open
do while not rsPostSkills.EOF
rsPostSkills.deleteRecord
rsPostSkills.moveNext
loop
End Sub

</script>
 
the idea would be to present this on the first page, before proceeding to your second page, so that the second page would not need to bother with any confirmations, it could just do its work. your code comment 'if they say yes then delete if they say no, return to page could be avoided, by simply confirming before leaving the first page.

OR:

as you've discovered, the msgbox function does not work on the server. if you really needed to do this, you could build a third page, which would act solely as your confirmation page. you could make this confirmation page a popup, and have it close itself and call the final processing page if the YES button was clicked. if NO was clicked the popup page could be closed with no further actions.

good luck!
 
This all needs to be done on one page, which is an asp page, so the first idea won't work, and I'm not sure about pop up windows, but I found this idea and I was wondering if you could help me make it work.

response.write &quot;<SCRIPT Language='javascript'>&quot; & vblf &_
&quot; confirm('&quot; & msgString & &quot;');&quot; & vblf &_
&quot; </SCRIPT> &quot;

And also, if I could set confirm to a variable first and then check, if confirm then go ahead with the delete, else, response.end (which is what I meant by return to page, this is a sub called by an onClick server side on an asp page.)

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top