Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confirm delete 1

Status
Not open for further replies.

LucasH

IS-IT--Management
Oct 28, 2003
93
US
Hi guys,

I am not that good with javascript and fairly new to .NET.

Can someone help me figure out how to enagle a confirm pop-up box when clicking a button on a webform (not in a datagrid). The button's click event will execute a SQL Delete command against my db, but I want a confirming box to show first to the user....

Thanks.
 
First you have to add an onclick attribute to your button:
Code:
[b]Page_Load Event:[/b]
Dim msg As String
msg = "return confirm('Are you sure you want to Delete?');"
btn.Attributes.Add("onclick", msg)

Then in the clicked event of the button, do your database delete code.

Jim
 
Using ASP.Net 2.0 :


If MsgBox("Delete?", MsgBoxStyle.SystemModal Or MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Question, "confirm") = MsgBoxResult.Yes Then
' Delete code here
Response.Write("Deleted!")
Else
Response.Write("Delete Canceled")
End If


Regards
 
TipGiver.. I belive the MsgBox will only display on the server, not the client.
 
Thanks guys, I will give it a shot and let you know...
 
jbenson -


super easy, that worked like a charm. THanks
 
I belive the MsgBox will only display on the server, not the client

I tested that before posting
 
TipGiver.. I did too and it worked if I created the project locally(file system), but if I created the project using HTTP it did not work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top