[CLOSED] I get error when creating (in codebehind) two windows in same page.

  1. #1

    [CLOSED] I get error when creating (in codebehind) two windows in same page.

    Hi!

    I get error when creating (in codebehind) two windows in same main page...
    The window ID are diferents...

    Follow sample project.

    <%@ Page Language="vb" %>
    <%@ 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 Sub AddWindow2()
            Dim wnd As Ext.Net.Window
            wnd = getWindow("~/test28.aspx", "test28")
            Me.Form.Controls.Add(wnd)
            wnd.Render()
            wnd.Show()
        End Sub
        
        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
            Dim successHandler As String
           
            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
    
            successHandler = String.Format("function (result) {{ if (result) {{  Ext.defer({0}.close, 1, {0}); }}}}", wnd.ClientID)
            btn.OnClientClick = String.Format("{0}.getBody().{1}({{ success : {2} }});", wnd.ClientID, "Ext.net.DirectMethods.Save", successHandler)
    
            '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" %>
    <%@ 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">
        <ext:Button runat="server" ID="btnCreateWindow" Text="Create and Show Second Window" OnClientClick="parent.Ext.net.DirectMethods.AddWindow2();" />
        </form>
    </body>
    </html>
    <%@ Page Language="vb" %>
    <%@ 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>
        <ext:ResourceManager ID="resManagerSGCO" runat="server" /> 
        <form id="form1" runat="server">
        
        </form>
    </body>
    </html>
    Last edited by Daniil; Mar 19, 2012 at 7:47 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Any details about the error?
  3. #3
    Hi Danill!

    The errors does not occurs to you?

    Well... The first 'alert' that anything does not right is the button 'Ok' of second window (test28). The text of this button is unaligned.
    Attachment 3942

    If I click in 'Cancel' button of second window (test28) to close the window, when the focus move to first window (test27) the buttons of this window are blank
    Attachment 3944

    and this errors occurs:
    Attachment 3943

    The two windows are created in codebehind, in Test26.aspx page...
    I tested with I.E 9.0.8112.16421, but the error occurs in FireFox too...
    I have the DP1 version...
  4. #4
    Hi,

    I didnot test your sample but i see that you use the same IDs for buttons in both windows. Therefore ids conflict is presented on the client side.
    Please ensure that all widgets have unique id (or don't define id, unique id will be generated autiomatically)
  5. #5
    Quote Originally Posted by supera View Post
    The errors does not occurs to you?
    Well, with the details about the errors I will, at least, know what I should reproduce.

    On the other hand, sometimes it's not required for us to reproduce the error since we can answer immediately pointing out where the problem might lay. So, it might economy your and our time.

    Quote Originally Posted by supera View Post
    I have the DP1 version...
    What do you think about updating to the last sources?

    Generally, we can't support DP1 anymore and should concentrate on the bug fixing of the Beta release.
  6. #6
    Hi Daniil!

    What do you think about updating to the last sources?
    I update yesterday from sources of SVN, but had to go back... Some things were working fine stopped working with the last SVN sources.
    I decided to go back and wait for the DP2 to not overload you with problems that will probably come out next changelog.

    What do you think? I will update the version and going over the problems? I even prefer! Or with the DP2 will see a new changelog?
  7. #7
    Quote Originally Posted by supera View Post
    What do you think? I will update the version and going over the problems? I even prefer! Or with the DP2 will see a new changelog?
    Well, we update CHANGELOG on the fly as far as we find new changes. There is no plan to make a separate CHANGELOG for DP1/Beta differences.

    I update yesterday from sources of SVN, but had to go back... Some things were working fine stopped working with the last SVN sources.
    Well, it's sadly, but inevitably at this stage.

    Personally, I would prefer to update even if some functionality will be broken.

    And, finally, your bug reports are the great help for us!

    I decided to go back and wait for the DP2 to not overload you with problems
    We are always glad to help and investigate a problem.
  8. #8
    Hi Vladimir...

    You are right! If I set the ID property this way, works fine:
    btn.ID = "btnOk" & (New System.Random).Next(Integer.MaxValue).ToString
    Thanks a lot...

    Could you explain a little better about these IDs in client-side?
    I generate different IDs for windows. I thought that I generate different ID for the window would be sufficient, since the button is contained in the window. This is not the behavior?
  9. #9
    Hi Daniil!

    Thanks for your conjectures. I think is better remove the bandage quickly.
    I'll update. Not a big problem for small changes necessary.
    The ext.net 2.x is an excellent set of components and we are very pleased with the results.

    Thanks a lot

Similar Threads

  1. Right Way of creating multiple windows.
    By Mauricio Rojas in forum 1.x Help
    Replies: 1
    Last Post: Feb 22, 2012, 8:33 PM
  2. [CLOSED] Creating DirectEvent from codebehind
    By krzak in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 01, 2011, 10:17 AM
  3. Problem with creating Dynamic Windows on Desktop
    By marcelodecon in forum 1.x Help
    Replies: 0
    Last Post: Apr 16, 2010, 11:25 AM
  4. Replies: 2
    Last Post: Mar 15, 2010, 1:45 PM
  5. Creating a Store From CodeBehind
    By ahmetmeral in forum 1.x Help
    Replies: 5
    Last Post: Dec 14, 2008, 5:14 PM

Posting Permissions