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

Page 1 of 2 12 LastLast
  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]
  2. #2
    Hi,

    You should set up a respective Success handler.
    Dim successHandler As String
    successHandler = String.Format("function (result) {{ if (result) {{ {0}.close(); }}}}", wnd.ClientID)
    btn.OnClientClick = String.Format("{0}.getBody().{1}({{ success : {2} }});", wnd.ClientID, "Ext.net.DirectMethods.Save", successHandler)
    P.S. Please leave only:
    <%@ Page Language="vb" %>
    in your samples instead of
    <%@ Page 
        Language="vb" 
        AutoEventWireup="false" 
        CodeBehind="Text26.aspx.vb" 
        Inherits="WebApplication3.Text26" %>
    We just always need to remove it.
  3. #3
    Hi Daniil

    Now, I get a error when the window is closed!

    In message box is written!
    Runtime Error in Microsoft JScript: 'Ext' is undefined

    Attachment 3941

    P.S. Please leave only:
    <%@ Page Language="vb" %>
    Ok! I´m sorry! I will send my code in this format...
  4. #4
    I was unable to reproduce the problem using the code from the initial post.

    Could you provide a sample?
  5. #5
    The errors occurs in same sample project...

    I've had other errors that you could not reproduce. I think it is because my version
    of DP1...

    I would like download a new version of DP1, but you recomended that I stay waiting the DP2.
  6. #6
    I've tried with DP1 as well - no error on my side.

    I would like download a new version of DP1, but you recomended that I stay waiting the DP2.
    Well, there is some misunderstanding.

    There is no new version of DP1 and we didn't plan it. We planned to release DP2.

    But made the Beta release which available for the community also.

    For you, as a premium member, I would suggest to update directly from SVN, because we hourly (or even minutely) fix reported bugs.
    http://svn.ext.net/premium/branches/2.0/

    In other words, the SVN version is already far enough from Beta release.

    More official info about the release will be available soon.
  7. #7
    Hi Daniil!

    SVN version is what I want and this is what I meant with 'new version of DP1'... Excuse me for not expressing myself correctly.
    Thanks a lot for indicate the url to SVN. I'm keeping my ext.net updated from this point forward.

    Well... I downloaded source codes with SVN, compile and update the dlls from url http://svn.ext.net/premium/branches/2.0/.
    After this, the <directmethods> don´t works any more.
    Probably, I don´t updating correctly.
    There are a guide or help to update and compile source codes of ext.net from SVN?
  8. #8
    Quote Originally Posted by supera View Post
    Probably, I don´t updating correctly.
    There are a guide or help to update and compile source codes of ext.net from SVN?
    I bet you did it correctly.

    Quote Originally Posted by supera View Post
    After this, the <directmethods> don´t works any more.
    Please try to replace
    Ext.net.DirectMethods
    with
    App.direct
    or set up
    DirectMethodNamespace="Ext.net.DirectMethods"
    for the ResourceManager.
  9. #9
    Replacing App.direct, works fine the DirectMethods

    But the error persisted:

    Runtime Error in Microsoft JScript: 'Ext' is undefined

    I need update the extjs or recompile this?
  10. #10
    Quote Originally Posted by supera View Post
    I need update the extjs or recompile this?
    No, you should not.

    Could you provide the latest code that you are trying with the exactly steps to reproduce the problem?
Page 1 of 2 12 LastLast

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