how add window close OnEvent?

  1. #1

    how add window close OnEvent?

    
     protected void ButtonOK_Click(object sender, Ext.Net.DirectEventArgs e)
            {
                showWindow(Icon.ApplicationDouble, "winTmp", "测试窗口", "Child.aspx", 400, 500, true, true, false, true);
            }
    
    
    public void showWindow(Icon iconTemp, string strTmpID, string strTmpTitle, string strTmpUrl, int intTmpWidth, int intTmpHeight, bool boolTmpModal, bool boolTmpClosable, bool boolTmpMaximizable, bool boolTmpResizable)
            {
                var win = new Window
                {
                    ID = strTmpID,
                    Icon = iconTemp,
                    Title = strTmpTitle,
                    Width = intTmpWidth,
                    Height = intTmpHeight,
                    Hidden = false,
    
                    Modal = boolTmpModal,
                    Collapsible = false,
                    Closable = boolTmpClosable,
                    Maximizable = boolTmpMaximizable,
                    Resizable = boolTmpResizable
    
                                    
                };
    
                // How to do "OnWindowTmpClose"
                
    
                win.AutoLoad.Url = strTmpUrl;
                win.AutoLoad.Mode = LoadMode.IFrame;
                win.Render();
                win.Show();
                //return win;
    
            }
    
    
    protected void OnWindowTmpClose(object sender, Ext.Net.DirectEventArgs e)
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Title = "信息",
                    Message = "关闭事件",
                    Width = 200,
                    Buttons = Ext.Net.MessageBox.Button.OK
                    
    
                });
            }
  2. #2
    Hi,

    To use Close event it needs to set Window's CloseAction to Close and use this code.
    win.DirectEvents.Close.Event += OnWindowTmpClose;
    Also please note when you create a control dynamically and use any DirectEvent then this control should be recreated during each request (e.g. in Page_Load). In a different way you will get a null pointer exception.

    I would suggest you to use DirectMethod instead of DirectEvent. With DirectMethod you could avoid recreating of control.

Similar Threads

  1. [CLOSED] how to close window after click button in this window
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 22, 2012, 2:48 PM
  2. [CLOSED] How to remove 'X' (window close) for popup window?
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 31, 2011, 3:50 AM
  3. [CLOSED] Problem to close Window which has another Window inside
    By asztern in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Dec 21, 2010, 5:33 PM
  4. Close window
    By abis in forum 1.x Help
    Replies: 11
    Last Post: Dec 11, 2010, 9:50 AM
  5. Replies: 1
    Last Post: Apr 01, 2009, 12:24 PM

Posting Permissions