Re: msgbox

Tech-Archive recommends: Fix windows errors by optimizing your registry



"win" <a@xxxxx> wrote in message news:OwoNxNLvIHA.524@xxxxxxxxxxxxxxxxxxxxxxx

I've created a gridview and it has a delete button on each row. "<asp:CommandField ShowDeleteButton="True" />".
I want to pop up a messagebox to ask the user Yes/No to ensure to delete the data instead of directly deleted the record.
Can you help me?

As Steven has already explained, server-side code runs on the server and client-side code runs on the client.

MsgBox is a function found in VB Classic and VBScript.

Although you can still use VBScript as a client-side language in ASP.NET, this is not recommended because it will work only in IE.

Therefore, to achieve the functionality you require, you need to use client-side JavaScript.

The JavaScript equivalents of MsgBox is alert();, confirm(); and prompt();
http://www.google.co.uk/search?hl=en&rlz=1T4GZEZ_en-GBGB252GB252&q=JavaScript+alert+confirm&meta=

E.g. to ask the user to confirm that they want to do something, you might use the following:

<asp:Button ID="MyButton" runat="server" Text="Delete" OnClick="MyButton_Click" OnClientClick="return confirm('Are you sure?');" />



--
Mark Rae
ASP.NET MVP
http://www.markrae.net

.


Quantcast