javascript confirm fires after deletion instead of before

T

TJS

javascript "confirm" fires after deletion instead of before deletion.
how do I get this to stop the processing ?



code
==================
Sub ShowAlert(ByVal s As string)
RegisterClientScriptBlock("CSP-showconfirm-function", _
"<s"+"cript language=""JavaScript"">" & vbCrLf & _
"function Show_confirm(s) {" & _
"return confirm(s); " & _
"}" & vbCrLf & _
"</s" + "cript>")
RegisterStartupScript("CSP-showconfirm", _
"<s"+"cript language=""JavaScript"">Show_confirm('" & _
s & "');</s"+"cript>")
End Sub


Sub Delete_Click(Sender As Object, e as System.Web.UI.ImageClickEventArgs)
call ShowAlert("Delete?")
Call delete()
End Sub


......

<form ...
<asp:ImageButton id="Btn_Delete" onclick="Delete_Click" Runat="Server"
ImageUrl="~/img/delete.gif" />
</form>
 
E

Eliyahu Goldin

Instead of all this Register... mess put just one line in the Page_Load
event:

Btn_Delete.Attributes("onclick")="return confirm('Delete?');"

And get rid of "call ShowAlert("Delete?")" either.

Eliyahu
 
H

Hans Kesting

TJS said:
javascript "confirm" fires after deletion instead of before deletion.
how do I get this to stop the processing ?



code
==================
Sub ShowAlert(ByVal s As string)
RegisterClientScriptBlock("CSP-showconfirm-function", _
"<s"+"cript language=""JavaScript"">" & vbCrLf & _
"function Show_confirm(s) {" & _
"return confirm(s); " & _
"}" & vbCrLf & _
"</s" + "cript>")
RegisterStartupScript("CSP-showconfirm", _
"<s"+"cript language=""JavaScript"">Show_confirm('" & _
s & "');</s"+"cript>")
End Sub


Sub Delete_Click(Sender As Object, e as
System.Web.UI.ImageClickEventArgs) call ShowAlert("Delete?")
Call delete()
End Sub


.....

<form ...
<asp:ImageButton id="Btn_Delete" onclick="Delete_Click" Runat="Server"
ImageUrl="~/img/delete.gif" />
</form>

What happens in your Delete_Click is this:
1) you add some script blocks to be rendered eventually
2) then you call delete ()
After this the page renders & gets sent to the browser,
which will display the confirm (which has nowhere to return to)


Hans Kesting
 
T

TJS

tried tht , but it does not fire at all


Eliyahu Goldin said:
Instead of all this Register... mess put just one line in the Page_Load
event:

Btn_Delete.Attributes("onclick")="return confirm('Delete?');"

And get rid of "call ShowAlert("Delete?")" either.

Eliyahu
 
T

TJS

the confirm box does not fire , the event fires


Eliyahu Goldin said:
What doesn't fire? The confirm box or the server event? Check if the
server
event set up correctly.

Eliyahu
 
E

Eliyahu Goldin

What doesn't fire? The confirm box or the server event? Check if the server
event set up correctly.

Eliyahu
 
E

Eliyahu Goldin

Try

Btn_Delete.Attributes("onclick")=String.Format("\"{0}\"", "return
confirm('Delete?');")

Eliyahu
 
T

TJS

throws this error


Compiler Error Message: BC30518: Overload resolution failed because no
accessible 'Format' can be called with these arguments:
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top