By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

need help determining the return value of a generated js onChange event

P: n/a
can anyone help me fathom out how to use this bit of code:

Public Class Utilities
Public Shared Sub CreateConfirmBox(ByRef txt As WebControls.TextBox,
_
ByVal strMessage As String)
txt.Attributes.Add("onchange", "return confirm('" & strMessage &
"');")
End Sub
End Class

invoked thusly:
Utilities.CreateConfirmBox(Me.txtDelete, *"Are you sure you want to
delete (this uses the Utilities Class)?")

Works great. However....

The ever-so-helpful page I stole this from explains:
The client-side JavaScript confirm(string) function displays a confirm
message box, displaying the string message passed into the function.
Recall that confirm message boxes provide both "OK" and "Cancel"
buttons. If the "OK" button is clicked, confirm() returns true; if
"Cancel" is clicked, it returns false. The return keyword is used to
return the result of the confirm message box. If a value of false is
returned, then the form is not submitted.

What it's NOT telling me is how to get the value returned by the
javascript confirm(). I've already determined that I can't assign some
sort of flag to either the call or the class. This would be ever so
helpful if I can just figure out how to get the true/false value so
that I can handle program flow.

If the answer turns out to be blindingly obvious, I'll be very annoyed
at myself, but at the same time eternally grateful to whomsoever turns
the light on. Thanks!

MDBloemker
md********@hotmail.com
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
This code would work on a submit button onclick event. because by default
if you return true the submit continues and if you return false the submit
terminates. Now, if you use it on a textbox, you will not get the same
results.

What are you confirming a delete of on the change event of a textbox?

There are a couple work arounds if you were trying to do this on the
onchange event, but I would need some more info on what exactly you are
trying to do. ie. Are you planning on submitting a form when the change
something, or are you planning on not letting them change the value in a
text field.

"MDBloemker" <md********@hotmail.com> wrote in message
news:20*************************@posting.google.co m...
can anyone help me fathom out how to use this bit of code:

Public Class Utilities
Public Shared Sub CreateConfirmBox(ByRef txt As WebControls.TextBox,
_
ByVal strMessage As String)
txt.Attributes.Add("onchange", "return confirm('" & strMessage &
"');")
End Sub
End Class

invoked thusly:
Utilities.CreateConfirmBox(Me.txtDelete, "Are you sure you want to
delete (this uses the Utilities Class)?")

Works great. However....

The ever-so-helpful page I stole this from explains:
The client-side JavaScript confirm(string) function displays a confirm
message box, displaying the string message passed into the function.
Recall that confirm message boxes provide both "OK" and "Cancel"
buttons. If the "OK" button is clicked, confirm() returns true; if
"Cancel" is clicked, it returns false. The return keyword is used to
return the result of the confirm message box. If a value of false is
returned, then the form is not submitted.

What it's NOT telling me is how to get the value returned by the
javascript confirm(). I've already determined that I can't assign some
sort of flag to either the call or the class. This would be ever so
helpful if I can just figure out how to get the true/false value so
that I can handle program flow.

If the answer turns out to be blindingly obvious, I'll be very annoyed
at myself, but at the same time eternally grateful to whomsoever turns
the light on. Thanks!

MDBloemker
md********@hotmail.com

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.