[CLOSED] Problem opening a Window that contains UserControl

  1. #1

    [CLOSED] Problem opening a Window that contains UserControl

    My goal is to open a new modular popup window that will fill up the screen, and inside is based on whatever ASCX file. But somehow the popup window is always empty. Can you advice if my implementation is wrong, or if there is a better way to do this? I wanted to use window so its modular and still inside my main page.

    Main Page:
    <ext:Panel ID="Panel1" runat="server" Border="false" ButtonAlign="Right">
      <Items>
        <ext:Button ID="Button1" runat="server" Text="Print">
            <DirectEvents>
                <Click OnEvent="DE_Window" Before="getScreenSize(this, extraParams)">
                    <ExtraParams>
                        <ext:Parameter Name="ScreenWidth" Value="Ext.getBody().getViewSize().width" Mode="Raw" />
                        <ext:Parameter Name="ScreenHeight" Value="Ext.getBody().getViewSize().height" Mode="Raw" />
                    </ExtraParams>                                        
                </Click>
            </DirectEvents>
        </ext:Button>
      </Items>
    </ext:Panel>
    
    
    <ext:Window ID="Window1" runat="server" Title="Report" Icon="Printer" Hidden="true"
         Height="480px" Width="640px" 
         Padding="5" Collapsible="true" Modal="true">
        <Items></Items>
    </ext:Window>
    Main Page (Code Behind)
    public void DE_Window(object sender, DirectEventArgs e)
    {
        UserControl ucUserControl;
        ucUserControl = (UserControl)this.LoadControl("UserControl.ascx");
        ucUserControl.ID = "UserControl_ID";
        this.Window1.ContentControls.Add(ucUserControl);
    
        int height = 0; int.TryParse(e.ExtraParams["ScreenHeight"], out height);
        int width = 0; int.TryParse(e.ExtraParams["ScreenWidth"], out width);
    
        if (height > 0) this.Window1.Height = new Unit(height);
        if (width > 0) this.Window1.Width = new Unit(width);
    
        this.Window1.Show();
    }
    UserControl.ascx
    <div>This is a user control</div>
    Thanks, J
    Last edited by geoffrey.mcgill; Sep 26, 2011 at 3:52 AM. Reason: [CLOSED]
  2. #2
    Hi,

    It needs to call .UpdateContent() for the Window as well.

    Here is a full example.

    .aspx

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        public void OpenWindow(object sender, DirectEventArgs e)
        {
            UserControl ucUserControl;
            ucUserControl = (UserControl)this.LoadControl("UserControl.ascx");
            ucUserControl.ID = "UserControl_ID";
            this.Window1.ContentControls.Add(ucUserControl);
            
            this.Window1.UpdateContent();
    
            int height = 0,
                width = 0;
            int.TryParse(e.ExtraParams["ScreenHeight"], out height);
            int.TryParse(e.ExtraParams["ScreenWidth"], out width);
    
            this.Window1.SetSize(width, height); 
            
            this.Window1.Show();
        }
    </script>
    <!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>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Button runat="server" Text="Print">
                <DirectEvents>
                    <Click OnEvent="OpenWindow">
                        <ExtraParams>
                            <ext:Parameter 
                                Name="ScreenWidth" 
                                Value="parseInt(Ext.getBody().getViewSize().width * 0.9)" 
                                Mode="Raw" />
                            <ext:Parameter 
                                Name="ScreenHeight" 
                                Value="parseInt(Ext.getBody().getViewSize().height * 0.9)" 
                                Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Window 
                ID="Window1" 
                runat="server" 
                Title="Report" 
                Icon="Printer" 
                Hidden="true"
                Modal="true" />
        </form>
    </body>
    </html>
    .asxc
    <%@ Control Language="C#" ClassName="TestUC" %>
    
    <div>This is a user control</div>
  3. #3
    I am having the error:

    Microsoft JScript runtime error:
    'ctl00_ContentPlaceHolder_Body_TrendingChart_Windo w1' is undefined


    with the code showing:

    Ext.net.replaceContent(ctl00_ContentPlaceHolder_Body_TrendingChart_Window1,"ctl00_ContentPlaceHolder_Body_TrendingChart_Window1_Content",["<div id=\"ctl00_ContentPlaceHolder_Body_TrendingChart_Window1_Content\" class=\"x-hidden\">","<div>This is a user control</div></div>"].join(''));Ext.net.ResourceMgr.registerIcon(["Printer"]);Ext.net.ResourceMgr.registerIcon(["Printer"]);ctl00_ContentPlaceHolder_Body_TrendingChart_Window1.show();

    Since this is a UserControl loading another UserControl, I may have missed something. I will review my codes on Monday. Please don't close this ticket yet.

    Thanks, J
    Last edited by Daniil; Sep 23, 2011 at 9:33 AM. Reason: Please use [CODE] tags
  4. #4
    Please try to set up IDMode.Explicit for the Window1.
  5. #5
    Hi Daniil,

    Thanks, the last piece of code resolved my issue. Please close this thread.

    Regards, J

Similar Threads

  1. Replies: 1
    Last Post: May 29, 2013, 6:00 PM
  2. Replies: 8
    Last Post: Feb 15, 2012, 9:04 AM
  3. [CLOSED] Problem opening a popoup window
    By sisa in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 15, 2011, 12:31 PM
  4. [CLOSED] Rendering Problem: UserControl in a TabPanel in a Window
    By reto.ruemmeli in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 24, 2010, 7:57 AM
  5. Replies: 3
    Last Post: Jun 05, 2008, 11:31 PM

Posting Permissions