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!

Asking Confirmation within ASP

Status
Not open for further replies.

melginger

Programmer
Jul 27, 2001
54
CA
I know that you can't make msgbox in asp for confirmation because ASP is server side... So you have to code your confirm box in Javascript like:

<script type="text/javascript">

confirm("Your text here");

</script>

But, I have only found application that use that confirm code on the Onclick of button. Nothing within the code. So for now, I can make the box appear but I can't retreive the result (wich button have been clicked).


I want to ask my user if they want to continue during the process. It is possible or not?

Thanks
 
Yes, it's possible, but without at least part of the code you have, there's no way to help you. And this should be in the Javascript forum, too.

Lee
 
trollacious, I don't know why you freely say that my thread isn't in the good forum...

I'm programming in ASP (i think i'm in the right forum!) but I want to know how to make a confirm box within my code... ASP can't directly... Js offers possibilities...

Unless you have somthing positive to give to someone, maybe you should avoid posting unvaluable answers!

For my code it's simple, I explain it in my first posting. I have something like

<%
Call Function1
Call Function2

'I WANT A CONFIRM BOX HERE BEFORE:
If Yes Then
Call Function3
End if
%>



 
You cannot call a client-side function from within your server-side code, which I believe is why trollacious was pointing out that this question may be more relative to the javascript forum.

About the closest you could come to simulating what you want is to call that confirm code in the previous page, or break your current page into two pages with the first page submitting the result of the confirm box to the second page.

Depending on what your previous page looks like, you may be able to just embed the confirm inside the button/link/etc that brings the end user to the current page. If you have two pieces of code that may execute based on the what the user clicked in the confirm box, then you could use javascript to add a value to the URL of the ASP page dpeending on whether they click OK or Cancel. Again, this is still mostly a javascript question, as the only ASP involved would be reading that new QueryString value in the second page.

-T

barcode_1.gif
 
As per madanthrax's post, you can set the client side scripting language to VBScript and use the normal VB function "msgbox" if this is your preference. You can set this just for a small scriptlet it you prefer (i.e. in the <script> tags) and do all the rest of your client side scripts/pages in Javascript. (warning: browser compatibility!)

Failing that you can use javascript too.. (which is far more compatible)

Code:
var myResult = confirm("Your Question Here");
alert(myResult);

// OK = True
// Cancel = False

The VBScript client side is more functional for this particular requirement(msgbox), though it is less compatibile with browsers - support mostly by IE (if at all by any other browser)

Also, you can use VBScript or Javascript(or JScript) at either the Server or the Client by specifying it in the preamble...

i.e.

<%@ Language=VBScript %>
in your asp files, you can also set this to JScript (which is similar in syntax to Javascript - with the relevant server side functions)

or <script type="text/Javascript"> etc, again can be replaced with VBScript

Though, having said that - I would recommend keeping it as simple as you can, and leave Javascript at the client, and keep VBScript at the server.

Hope that helps,
Damian


A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top