Pop-up?message box?

C

Chris

What is the best way to display pop-up messages, i.e. Confirmation, etc.?
I'm using vb in asp.net.
I've read another posting on the 'confirmation' subject but am a little unclear.
I'd like to confirm a delete operation using a pop-up. On button, once clicked, goes straight to the Sub that deletes the record.

Should I place a condition in the sub asking the user to confirm delete?

I normally use a JavaScript routine that returns confirmation. But if I have the button going to the Sub then how could I also confirm?

<asp:Button Text="Delete" class="label" OnClick="deleteuserinfo" ID="btndeleteuser" Runat="server" />

Thanx!!!
 
K

Ken Cox [Microsoft MVP]

Hi Chris,

Here's one approach. Add the client-side script during the Load event and
put it into the button.

You proceed with the deletion only if the confirm() method returns true:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
btndeleteuser.Attributes.Add("onclick", _
"javascript:return confirm('Delete it?');")
End Sub

Private Sub btndeleteuser_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btndeleteuser.Click
Response.Write("Deleted")
End Sub

<form id="Form1" method="post" runat="server">
<asp:Button Text="Delete" class="label" ID="btndeleteuser" Runat="server"
/>
</form>

Does this help?

Ken
Microsoft MVP [ASP.NET]
 
C

Chris

I didn't really understand, then I added it to my Page Load and it works. So it appears to put the Javascript routine (Like I've used before) in the button attributes. Cool!

Thanx.


Ken Cox said:
Hi Chris,

Here's one approach. Add the client-side script during the Load event and
put it into the button.

You proceed with the deletion only if the confirm() method returns true:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
btndeleteuser.Attributes.Add("onclick", _
"javascript:return confirm('Delete it?');")
End Sub

Private Sub btndeleteuser_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btndeleteuser.Click
Response.Write("Deleted")
End Sub

<form id="Form1" method="post" runat="server">
<asp:Button Text="Delete" class="label" ID="btndeleteuser" Runat="server"
/>
</form>

Does this help?

Ken
Microsoft MVP [ASP.NET]


Chris said:
What is the best way to display pop-up messages, i.e. Confirmation, etc.?
I'm using vb in asp.net.
I've read another posting on the 'confirmation' subject but am a little
unclear.
I'd like to confirm a delete operation using a pop-up. On button, once
clicked, goes straight to the Sub that deletes the record.

Should I place a condition in the sub asking the user to confirm delete?

I normally use a JavaScript routine that returns confirmation. But if I
have the button going to the Sub then how could I also confirm?

<asp:Button Text="Delete" class="label" OnClick="deleteuserinfo"
ID="btndeleteuser" Runat="server" />

Thanx!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top