[CLOSED] When directMethod returns True, I wish that window is closed

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] When directMethod returns True, I wish that window is closed

    Hi!

    I have two aspx page.
    In main page (test26.aspx), I create a window (in codebehind) and I load within this window the test27.aspx page.
    In test27.aspx (child page) I have a directmethod called Save, and this functions return true or false.
    I wish when the directMethod Save returns true, the window was closed.

    the code to call a directMethod is in btnOk of window:
     btn.OnClientClick = wnd.ClientID & ".getBody().Ext.net.DirectMethods.Save();"
    Any help?

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Text26.aspx.vb" Inherits="WebApplication3.Text26" %>
    <%@ 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">
    
    <script runat="server">
        
        Protected Sub AddWindow(sender As Object, evt As Ext.Net.DirectEventArgs)
            Dim wnd As Ext.Net.Window
            wnd = getWindow()
            Me.Form.Controls.Add(wnd)
            wnd.Render()
            wnd.Show()
        End Sub
        
        Protected Function getWindow(Optional url As String = "~/test27.aspx", Optional pTitle As String = "test", Optional iconUrl As String = "") As Ext.Net.Window
            Dim wnd As New Ext.Net.Window
            Dim loader As New Ext.Net.ComponentLoader
            Dim btn As Ext.Net.Button
    
            loader.Url = url
            loader.Mode = Ext.Net.LoadMode.Frame
            loader.LoadMask.ShowMask = True
            loader.LoadMask.Msg = "Carregando..."
    
            wnd.ID = "window_" & (New System.Random).Next(Integer.MaxValue).ToString
            wnd.Title = pTitle
            If iconUrl <> "" Then
            Else
                wnd.Icon = Ext.Net.Icon.ApplicationForm
            End If
            wnd.AutoRender = False
            wnd.Collapsible = False
            wnd.Hidden = True
            wnd.AutoRender = False
            wnd.Maximizable = False
            wnd.Loader = loader
            wnd.CloseAction = CloseAction.Destroy
            wnd.Width = 500
            wnd.Height = 400
            
            btn = New Ext.Net.Button
            btn.ID = "btnOk"
            btn.Text = "Ok"
            btn.TextAlign = ButtonTextAlign.Center
            btn.Icon = Icon.Accept
            btn.OnClientClick = wnd.ClientID & ".getBody().Ext.net.DirectMethods.Save();"
            wnd.Buttons.Add(btn)
            
            btn = New Ext.Net.Button
            btn.ID = "btnCancel"
            btn.Text = "Cancel"
            btn.TextAlign=ButtonTextAlign.Center 
            btn.Icon = Icon.Cancel
            btn.OnClientClick = wnd.ClientID & ".close();"
            wnd.Buttons.Add(btn)
            
            Return wnd
    
        End Function
        
        <DirectMethod()>
        Public Sub ShowMessage()
            Dim mb As New Ext.Net.MessageBox
            mb.Alert("Parent alert!", "This messages is triggered in parent!").Show()
        End Sub
        
        <DirectMethod()>
        Public Sub ShowWindow()
            Dim wnd As Ext.Net.Window
            wnd = getWindow("~/test25.aspx")
            Me.Form.Controls.Add(wnd)
            wnd.Render()
            wnd.Show()
        End Sub
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="resManagerSGCO" runat="server"/> 
        <form id="form1" runat="server">
        <div>
            <ext:Button runat="server" ID="btnCreateWindow" Text="Create and Show Window" OnDirectClick="addWindow" />
        </div>
        </form>
    </body>
    </html>
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test27.aspx.vb" Inherits="WebApplication3.Test27" %>
    <%@ 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">
    <script runat="server">
        
        <DirectMethod()>
        Public Function Save() As Boolean
            Response.Write("Save triggered!!!")
            Return True
        End Function
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="resManagerSGCO" runat="server" /> 
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>
    Last edited by Daniil; Mar 14, 2012 at 7:17 PM. Reason: [CLOSED]

Similar Threads

  1. Replies: 10
    Last Post: Apr 25, 2013, 5:38 AM
  2. Replies: 6
    Last Post: Apr 02, 2012, 6:37 PM
  3. Replies: 3
    Last Post: Mar 19, 2012, 12:35 PM
  4. [CLOSED] Move a window to the left with constrainHeader = true
    By softmachine2011 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 01, 2011, 10:43 AM
  5. [CLOSED] Window toFront: true
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 20, 2011, 8:56 AM

Posting Permissions