It was a long time ago and i had much to learn about js and asp.net.
this out unf..
> Fair point about assuming javascript. It is better to be safe so code
> below has be changed.
> If b IsNot Nothing Then b.OnClientClick = "javascript:return
> confirm('Delete?');"
>
> I don't understand how a postback could have occured after returning
> false to the control's OnClick event.
> The line below should cause the button to never postback to the server
> no matter how many time it is clicked.
> If b IsNot Nothing Then b.OnClientClick = "javascript:return false;"
>
> Regards,
> Andy
>
> Edwin Knoppert wrote:
>> Btw, imo by removing "javascript:" from the line you assume that the
>> browser
>> interpret's the code as javascript by default.
>> Maybe you better keep "javascript:" in at all times.
>> I have not investigated this but i assumed this.
>>
>>
>>
>> <CaffieneRush@gmail.com> schreef in bericht
>> news:1149102085.178478.127330@j55g2000cwa.googlegroups.com...
>> >I finally see where the confusion comes from.
>> > The return we are talking about is not a return to the serverside code
>> > but to the button's click event. So cancel will cancel the click event
>> > while a confirm will continue with the click which would then go onto
>> > trigger a postback to the server.
>> >
>> > Take a look at Edwin's code in this thread to see a complete example of
>> > this in action.
>> > My only suggestion is that the line below can be simplified within
>> > Default2.aspx.vb:
>> > If b IsNot Nothing Then b.Attributes.Add("onclick",
>> > "javascript:window.event.returnValue=confirm('Delete?');")
>> >
>> > to:
>> > If b IsNot Nothing Then b.OnClientClick = "return confirm('Delete?');"
>> >
>> > Regards,
>> > Andy
>> >
>> > ps. If you are still resistant to this simple solution then you can use
>> > javascript to write the value of your ok variable to a hidden field in
>> > the page and check this hidden field on the postback.
>> >
>> > Averell wrote:
>> >> Hi, i'm a little confused with all those solutions. Meanwhile i did
>> >> this
>> >> and
>> >> i feel i'm close to the solution (??).
>> >> The only thing i miss is how to pass the result of the function
>> >> check()
>> >> to
>> >> VB.
>> >> Thanks
>> >>
>> >> Dim jv As String
>> >> jv = "function check()" _
>> >> & "{" _
>> >> & " alert('warning');" _
>> >> & " var ok=confirm(if you want to delete; click on OK');" _
>> >> & " if (!ok)" _
>> >> & " {" _
>> >> & " window.location.href='mult.aspx';" _
>> >> & " return false;" _
>> >> & "};" _
>> >> & "};" _
>> >> & "check();"
>> >>
>> >> Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "myscript",
>> >> jv,
>> >> True)
>> >>
>> >> dim x as string
>> >> x= result of function check() : HOW TO DO THIS?
>> >> if x="False" then e.cancel=True
>> >>
>> >>
>> >> <CaffieneRush@gmail.com> wrote in message
>> >> news:1149023245.227871.240380@y43g2000cwc.googlegroups.com...
>> >> > What Peter Kellner means is that you need to inject some clientside
>> >> > javascript when you're creating your delete button and return the
>> >> > results of the Confirm.
>> >> > In this scenario the RowDeleting serverside event would not even
>> >> > fire
>> >> > if the user clicks Cancel because the delete click would be
>> >> > cancelled
>> >> > on the clientside.
>> >> >
>> >> >
>> >>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/GridViewEx10.asp
>> >> > Do a search on the word 'OnClientClick' and you can see some
>> >> > specific
>> >> > code on delete confirmation.
>> >> >
>> >> > Regards,
>> >> > Andy
>> >> >
>> >
>