Button postback with confirmation

  1. #1

    Button postback with confirmation

    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"
            });
    
    
        }
    }
  2. #2
    Hi,

    Thanks for sharing.
  3. #3
    great sample
    very thanks
    I will write ExtJS articles coming soon

Similar Threads

  1. Confirmation with save button
    By Vaishali in forum 1.x Help
    Replies: 1
    Last Post: Feb 18, 2012, 10:13 AM
  2. Confirmation for save button
    By Vaishali in forum 1.x Help
    Replies: 0
    Last Post: Feb 13, 2012, 4:22 AM
  3. how run loadmask after confirmation button?
    By danilo in forum 1.x Help
    Replies: 2
    Last Post: Feb 08, 2012, 10:02 AM
  4. Replies: 1
    Last Post: Jul 15, 2011, 12:40 AM
  5. Button with Confirmation Delete...
    By Maia in forum 1.x Help
    Replies: 16
    Last Post: Mar 11, 2009, 9:59 AM

Posting Permissions