Re: msgbox
- From: "Mark Rae [MVP]" <mark@xxxxxxxxxxxxxxxxx>
- Date: Fri, 23 May 2008 12:03:46 +0100
"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
.
- Follow-Ups:
- Re: msgbox
- From: Steven Cheng [MSFT]
- Re: msgbox
- References:
- msgbox
- From: win
- RE: msgbox
- From: Steven Cheng [MSFT]
- Re: msgbox
- From: win
- msgbox
- Prev by Date: Re: Calling old C DLL for ASP.NET Web Service
- Next by Date: Re: using DataSet programatically without an sql server database
- Previous by thread: Re: msgbox
- Next by thread: Re: msgbox
- Index(es):