pagina aspx :
codice:
<HTML>
<HEAD>
<title>titolo</title>
<script language=javascript>
function conferma()
{
if (confirm("Sei sicuro di voler cancellare ?") == true)
return true;
else
return false;
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Button id="bottone" runat="server" Text="Clicca per cancellare!"></asp:Button>
<asp:Label id="Label1" runat="server"></asp:Label>
</form>
</body>
</HTML>
code-behind:
codice:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents bottone As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
bottone.Attributes.Add("onclick", "return conferma();")
End Sub
Private Sub bottone_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bottone.Click
Label1.Text = "Hai confermato !"
End Sub
End Class