JScript - handling OK/Cancel in confirmation box

C

Craig G

hi,

im only learning javascript, i have this little code snippet that i wish to
use. basically the code-behind page will display a little jscript confirm
message box

Public Sub ASPNET_MsgBox(ByVal Message As String)

System.Web.HttpContext.Current.Response.Write("<SCRIPT
LANGUAGE=""JavaScript"">" & vbCrLf)

System.Web.HttpContext.Current.Response.Write("confirm(""" & Message & """)"
& vbCrLf)

System.Web.HttpContext.Current.Response.Write("</SCRIPT>")

End Sub


what i was wanting to know. is what do i have to do in the HTML in order to
tell which button they click (OK/Cancel) on the confirm message box, so that
i can then call the correct function in my codebehind page.

Cheers,
Craig
 
G

Guest

I don't know why you are writing this function on server side. This could
have been a Javascript function within the page. In that case, it probably
would have made things easier for you. All you would have to do is add an
attribute to your aspnet button in code to call the Javascript Function

This article explains it better than me:

http://aspnet.4guysfromrolla.com/articles/021104-1.aspx
 
E

Eliyahu Goldin

Craig,

Usually you don't need to make a roundtrip to server just to make a
confirmation box. You should call confirm on client side in a client event
handler. There are several ways of passing information from client to
server. Most common one is using hidden input fields.

<input id="inhConfirm" type=hidden runat="server">
....
inhConfirm.value=confirm('message');

Eliyahu
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top