MessageBox


M

mac

Hi!

I've created a simple ASPX form that displays a record from a SQL Server
table. I have a "Delete" button on the form. When the user clicks it,
I want to prompt the user with
a message ("Are you sure you want to delete... ?").

I realize the Yes/No Messagebox can be done via Javascript -- but how do
I retrieve the Messagebox return value in my .ASPX page?
so I can act on it (i.e., to perform the delete)?


Thanks in Advance
Mac
 
Ad

Advertisements

M

Mark Rae

I realize the Yes/No Messagebox can be done via Javascript -- but how do
I retrieve the Messagebox return value in my .ASPX page?
so I can act on it (i.e., to perform the delete)?

return confirm('Are you sure you want to delete this record?');
 
V

ValliM

Hi Mac,

You can add the confirmation messagebox in aspx page as shown below.
You have to wirte the following code on the page load event , which adds an
onclick event to the asp.net button to
display a message box. When u click ok it will proceed to the delete
operation.
protected void Page_Load(object sender, EventArgs e)

{

bnDelete.Attributes.Add("onclick",

"return(confirm('Are you sure to delete?'));");

}

Regards,

Valli

(www.syncfusion.com)

ASP.Net FAQ:
http://www.syncfusion.com/faq/aspnet/default.aspx

Complete set of ASP.Net controls and components
http://www.syncfusion.com/toolsweb
 
R

Ray Booysen

Well, thats a bit vague. If the user clicks no/cancel, the form isn't
POSTed to the server so nothing changes. If the users clicks yes/ok,
then the form is POSTed back.

You can then assume that if the form is POSTed then the user clicked the
yes/ok button. If the user has javascript disabled, obviously you
cannot determine this.

Regards
Ray
 
S

Steve C. Orr [MVP, MCSD]

Here's some server side code that uses javascript to display a confirmation
message.

myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise the server code is never called in
response to the button click.

Here's more info:
http://SteveOrr.net/articles/ClientSideSuite.aspx
 
Ad

Advertisements

Ad

Advertisements


Top