"darrel" <no*****@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Is it possible to pre-empt the javascript function used to do a postback
from a linkbutton?
I'd like to use linkbutton to delete a record and want to add a
confirmation box via javascript "are you sure you want to delete this
record?" before it executes the postback. The javascript is
straightforward for this, but have no idea how to have that intercept the
post-back script.
Any JavaScript function which returns false will intercept a postback e.g.
<asp:Button ID="MyButton" runat="server" OnClick="MyButton_Click"
OnClientClick="return confirm('Are you sure you want to delete this
record?');" Text="Delete" />
In the above example, when a user clicks on the Delete button, they will be
prompted with a client-side Yes/No alert - if they click Yes, the postback
will happen and run the code in the server-side MyButton_Click method - if
they click No, the postback will be intercepted and nothing further will
happen...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net