Peter, i made a function and returned the confirm result, but even clicking
on Cancel, the record is deleted ...
I inserted an ALERT after the 'return false' and it's not executed. The Java
code stops indeed, but not the VB code deleting the row.
Is this the right way to proceed?
thanks
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles
GridView1.RowDeleting
Dim jv As String
jv = "<script language='javascript'>" _
& "function check()" _
& "{" _
& " alert('let op');" _
& " var ok=confirm('if you want to delete it, click on OK');" _
& " if (!ok)" _
& " {" _
& " window.location.href='mult.aspx';" _
& " return false;" _
& " alert('this is not shown');" _
& "};" _
& "};" _
& "check();" _
& "</script>"
Response.Write(jv)
End Sub
"PeterKellner" <> wrote in message
news:...
> On Mon, 29 May 2006 19:00:07 +0200, "Averell" <> wrote:
>
> >Hi,
> >
> >I made a gridview with VWD. The gridview has the Delete button set
> >(ShowDeleteButton="True" in the <asp:CommandField>).
> >It works perfect, but i would like to add a warning before the record is
> >deleted to prevent deleting a wrong record.
> >I did this in the code-behind file:
> >Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As
> >System.Web.UI.WebControls.GridViewDeleteEventArgs ) Handles
> >GridView1.RowDeleting
> > Dim jv As String
> > jv = "<script language='javascript'>" _
> > & " alert('beware!');" _
> > & "if (! confirm('if you want to delete it, click on OK'));" _
> > & " {window.location.href='mult.aspx'};" _
> > & "</script>"
> > Response.Write(jv)
> >End Sub
> >
> >I see effectively the warning, but when i click on OK or on Cancel of the
> >Confirm, in both cases the record is deleted.
> >Is it possible to prevent that, and if yes, how?
> >
> >Thanks for any hints
> >Averell
> >
> >
>
> You need to return the results of confirm.
> Peter Kellner
> http://peterkellner.net