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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox Help !!!!!!!!!!!! 2

Status
Not open for further replies.

pwel

Programmer
Aug 18, 1999
79
GB
Can anyone give me the correct syntax for using a MsgBox in ASP, as I keep getting errors....

Cheers.
 
Hello,
The nature of ASP (Active Server Page) is to do some actions on server. ASP is using VBScript for that. (VBScript server-side)
MsgBox is part of VBScript, but it's nature is to diplay something to the client, so actually it is part of VBScript client-side.
So you cannot use MsgBox in your ASP code.
Possible solutions:
1) ASP - use Response.Write ("Message")
2) Client-side VBScript
<script language=&quot;VBScript&quot;>
MsgBox &quot;Message&quot;
</script>
Hope this helps.
D.
 
Is there a way to redirect the user to another page depending on the outcome of the button click in the MsgBox.

i.e. (this does not work because the ASP executes first) but you will get the idea.

<script Language=vbscript>
intButtonClicked = MsgBox(&quot;Do you wish to add another?&quot;,68, &quot;Duplicate!&quot;)
if intButtonClicked = 6 then
'do nothing
End if
if intButtonClicked = 7 then

<%
Response.Redirect &quot;singleFeedTSearch.asp&quot;
%>
End if
</script>

Any ideas?

Cheers.
 
Hi,

Not that I know much about ASP or VBscript, but its easy in Javascript (which will work on both IE and Netscape):

<SCRIPT LANGUAGE=&quot;Javascript1.2&quot;>
if (confirm('Do you what to jump to TekTips?')) { window.location.href=&quot;}
</SCRIPT>

Sunaj
 
Hello,
First my thought was that you will need the client-side VBScript function that returns user input - InputBox. Check MSDN for more information.

Dim UserInput
UserInput = InputBox(&quot;Enter your destination&quot;)
MsgBox (&quot;You entered: &quot; & UserInput)

Then I realise that you are asking for redirecting.
In ASP Response.Redirect immediately goes to specified URL.
Again in client-side VBScript you could use
window.location.href = &quot;bbb.asp&quot; or
document.location.href = &quot;bbb.asp&quot;

Hope this helps.
D.
 
Dianal,

Thanks for your great suggestion. I had a msgbox that was being ignored because the response.redirect was hitting right away. Now, I have the window.location.href right under the msgbox code within the <Script> tag and it waits for the msgbox to redirect.

You get a star from me.

Thanks again,
Rob
 
MsgBox & InputBox are not part of ASP...It will not work !!
 
I have a similar issue, except I want to either include a hyperlink in the message box (not possible right?) or execute the hyperlink after the user presses OK. The link is not a page though, it is a .reg file to edit someone's registry settings. I need it to be in vbscript because it is part of a vbscript function that executes when the function has an error.
 
Visitor:
MsgBox and InputBox will work in client-side VBScript - it's just no-one would use client-side VBScript unless they had absolute control over what their audience browsed with - client-side VBScript only works for IE :p codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
I hope I never consider myself an 'expert'.
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top