ASP.NET Confirm dialog
Sample 1: ASP.NET
----------------------------------------------------------------------------------------------------
.aspx
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="return confirm('Do you really want to save?');" />
Sample 2: ASP.NET Call JAVASCRIPT Function
----------------------------------------------------------------------------------------------------
.aspx
<asp:Button runat="server" ID="btnUserDelete" Text="Delete" OnClick="BtnUserDelete_Click" OnClientClick="if ( ! UserDeleteConfirmation()) return false;" />
<script type="text/javascript">
function UserDeleteConfirmation() {
return confirm("Are you sure you want to delete this user?");
}
</script>
Sample 3: C#
----------------------------------------------------------------------------------------------------
.cs
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
btnSave.Attributes["Onclick"] = "return confirm('Do you really want to save?');";
}
}
沒有留言:
張貼留言