PDA

View Full Version : Button postback with confirmation



zach
Sep 26, 2011, 8:53 AM
Here's an example showing how to do a confirmation with an autopostback button.




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PB.aspx.cs" Inherits="PB" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
<script type="text/javascript">
var doPostbackWithConfirmation = function () {

var postBackFn = this.postback.fn
Ext.Msg.confirm('Confirm', 'Are you sure?', function (btn) {
//console.log(this, arguments);
if (btn == 'yes') { postBackFn(); }
});

return false;
}
</script>

<ext:Button runat="server" AutoPostBack="true" OnClick="DoServerWork" Text="Do Server Stuff">
<Listeners>
<Click Fn="doPostbackWithConfirmation" />
</Listeners>
</ext:Button>

</form>
</body>
</html>






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

public partial class PB : System.Web.UI.Page
{

protected void DoServerWork(object sender, EventArgs e)
{

Notification.Show(new NotificationConfig
{
Title = "Title",
Icon = Icon.Information,
Html = "Well Played"
});


}
}

Daniil
Sep 27, 2011, 11:48 AM
Hi,

Thanks for sharing.

ismailkocacan
Sep 28, 2011, 3:53 PM
great sample
very thanks
I will write ExtJS articles coming soon