[CLOSED] Multiple controls cache issue with user control on direct event...

  1. #1

    [CLOSED] Multiple controls cache issue with user control on direct event...

    I have 2 user controls and a default.aspx page with 2 buttons, on button click I load user control in aspx.

    Each user control had GridPanel and hidden window holding FormPanel. On AddNew click I show window on screen, first time it works fine but when I
    load second user control and click AddNew to show window... controls appears multiple times.

    Am I missing something here ?

    Screenshort
    Click image for larger version. 

Name:	Untitled.png 
Views:	259 
Size:	17.0 KB 
ID:	2928Click image for larger version. 

Name:	Untitled2.png 
Views:	273 
Size:	23.1 KB 
ID:	2929

    Code (default.aspx)
    <%@ Page Language="C#" %>
    <%@ 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 void onBtnClick1(object sender, DirectEventArgs e)
        {
            string strControlPath = "UserControl1.ascx";
            string strControlID = "uc1";
            /*??Loading User Coantrol??*/
            X.Js.Call("destroyFromCache", new JRawValue(CenterContainer.ClientID));
            BaseUserControl uc1 = (BaseUserControl)this.LoadControl(strControlPath);
            uc1.ID = String.Format("UC{0}", strControlID);
             
            CenterContainer.ContentControls.Add(uc1);
    
    
            X.Js.Call("putToCache", new JRawValue(CenterContainer.ClientID), uc1.ControlsToDestroy);
            
            CenterContainer.Render();
        
    
        }
    
        protected void onBtnClick2(object sender, DirectEventArgs e)
        {
            string strControlPath = "UserControl2.ascx";
            string strControlID = "uc2";
            
            /*??Loading User Coantrol??*/
            X.Js.Call("destroyFromCache", new JRawValue(CenterContainer.ClientID));
            BaseUserControl uc1 = (BaseUserControl)this.LoadControl(strControlPath);
            uc1.ID = String.Format("UC{0}", strControlID);
            
            CenterContainer.ContentControls.Add(uc1);
    
    
            X.Js.Call("putToCache", new JRawValue(CenterContainer.ClientID), uc1.ControlsToDestroy);
            
            CenterContainer.Render();
           
        }
        
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext Template </title>
        <script type="text/javascript">
            var destroyFromCache = function (container) {
                container.controlsCache = container.controlsCache || [];
                Ext.each(container.controlsCache, function (controlId) {
                    var control = Ext.getCmp(controlId);
                    if (control && control.destroy) {
                        control.destroy();
                    }
                });
            };
    
            var putToCache = function (container, controls) {
                debugger;
                container.controlsCache = controls;
            };
       </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <form id="form1" runat="server">
        <ext:Viewport ID="Viewport1" runat="server">
       <Items>
      
        <ext:BorderLayout ID="BorderLayout1" runat="server">
            <Center>
                <ext:Panel ID="MainPanel" runat="server" Border="true" Header="false" Layout="FitLayout"
                    AutoScroll="true" ButtonAlign="Center">
                    <Items>
                        <ext:Container ID="CenterContainer" runat="server" Layout="FitLayout" />
                    </Items>
                    <Buttons>
                        <ext:Button ID="Button1" runat="server" Text="Load UC1"  Scale="Medium">
                            <DirectEvents>
                                <Click OnEvent="onBtnClick1" DisableCaching="false" >
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="Button2" runat="server" Text="Load UC2" Scale="Medium">
                            <DirectEvents>
                                <Click OnEvent="onBtnClick2" DisableCaching="false">
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Buttons>
                </ext:Panel>
            </Center>
        </ext:BorderLayout>
         </Items>
       </ext:Viewport>
        </form>
    </body>
    </html>
    Code: UserControl 1
    <%@ Control Language="C#" ClassName="UserControl1" Inherits="BaseUserControl" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void MainStore_OnRefreshData(object sender, DirectEventArgs e)
        {
            
        }
        
        protected void recordNew(object sender, DirectEventArgs e)
        {
             
    
        }
    
        protected void recordEdit(object sender, DirectEventArgs e)
        {
            
        }
        protected void recordDelete(object sender, DirectEventArgs e)
        {
            
        }
        protected void recordSubmit(object sender, DirectEventArgs e)
        {
            
        }
        public override List<string> ControlsToDestroy
        {
            get
            {
                // we should return none lazy controls only because lazy controls will be autodestroyed by parent container
                return new List<string>
                {
    
                };
            }
        }
       
        
    </script>
    
    <ext:Store ID="StoreSalutation" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="HOCODE">
                <Fields>
                    <ext:RecordField Name="HOCODE" />
                    <ext:RecordField Name="Name" />
                    <ext:RecordField Name="Description" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:FitLayout ID="FitLayout1" runat="server">
        <Items> 
            <ext:GridPanel runat="server" ID="MainGrid" Border="false" StripeRows="true"
                Title="Leads " TrackMouseOver="true"   AutoExpandColumn="Name">
                <Store>
                    <ext:Store ID="MainStore" runat="server" AutoSave="false" ShowWarningOnFailure="false">
                        <Reader>
                            <ext:JsonReader IDProperty="HOCODE">
                                <Fields>
                                    <ext:RecordField Name="ApplicationHOCODE" />
                                    <ext:RecordField Name="PartnerHOCODE" />
                                    <ext:RecordField Name="Name" />
                                    <ext:RecordField Name="Description" />
                                    <ext:RecordField Name="IsTrial" Type="Boolean" />
                                    <ext:RecordField Name="StartDate" />
                                    <ext:RecordField Name="ExpiryDate" />
                                    <ext:RecordField Name="LogoURL" />
                                    <ext:RecordField Name="Version" />
                                    <ext:RecordField Name="Monthly" />
                                    <ext:RecordField Name="Yearly" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <TopBar>
                    <ext:Toolbar ID="Toolbar2" runat="server">
                        <Items>
                            <ext:Button ID="Button121" runat="server" Text="Add New" Icon="Add">
                                  <Listeners>
                                    <Click Handler="#{MainWindow}.show();" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="Button332" runat="server" Text="Edit" Icon="Pencil">
                                <DirectEvents>
                                    <Click OnEvent="recordEdit" />
                                </DirectEvents>
                            </ext:Button>
                            <ext:Button ID="Button123" runat="server" Text="Delete" Icon="Delete">
                                <DirectEvents>
                                    <Click OnEvent="recordDelete" Success="">
                                        <Confirmation ConfirmRequest="true" Message="Are you sure you want to delete?" Title="Confirm Delete" />
                                        <EventMask ShowMask="true" Target="Page" Msg="deleting..." />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarFill />
                            <ext:Label runat="server" ID="lblSearch" Text="Search:" />
                            <ext:ToolbarSpacer Width="5" />
                            <ext:ComboBox ID="optFields" SelectedIndex="0" runat="server" Width="180" EmptyText="Select Fields">
                                <Items>
                                    <ext:ListItem Text="Customer" Value="DisplayName" />
                                    <ext:ListItem Text="Application" Value="Name" />
                                    <ext:ListItem Text="Description" Value="Description" />
                                </Items>
                            </ext:ComboBox>
                            <ext:ToolbarSpacer Width="5" />
                            <ext:TriggerField ID="optQueryString" runat="server" Width="240">
                                <Triggers>
                                    <ext:FieldTrigger Icon="Clear" Qtip="<b>Clear</b><br/>Click to clear" />
                                    <ext:FieldTrigger Icon="Search" Qtip="<b>Search</b><br/>Click to search" />
                                </Triggers>
                                <Listeners>
                                    <TriggerClick Handler="
                                        if(index==0){#{optQueryString}.clear(); #{MainStore}.filter(#{optFields}.getValue(),'',true,false);}
                                        if(index==1){#{MainStore}.filter(#{optFields}.getValue(),#{optQueryString}.getValue(),true,false);} " />
                                </Listeners>
                            </ext:TriggerField>
                            <ext:ToolbarSpacer Width="5" />
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column DataIndex="HOCODE" ColumnID="HOCODE" Header="HOCODE" Hidden="true" />
                        <ext:Column DataIndex="Type" ColumnID="Type" Header="Type" Resizable="false" MenuDisabled="true"
                            Sortable="true" Width="100" />
                        <ext:Column DataIndex="Name" ColumnID="Name" Header="Name" Resizable="false" MenuDisabled="true"
                            Sortable="true" Width="180" />
                        <ext:Column DataIndex="FullAddress" ColumnID="FullAddress" Header="Full Address"
                            Resizable="false" MenuDisabled="true" Sortable="false" Width="220" />
                        <ext:Column DataIndex="CreatedDate" ColumnID="CreatedDate" Header="Created Date"
                            MenuDisabled="true" Sortable="false" Width="80">
                            <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y')" />
                        </ext:Column>
                        <ext:Column DataIndex="Phone" ColumnID="Phone" Header="Phone" Editable="false" MenuDisabled="true"
                            Sortable="false" Resizable="false" Width="80" />
                        <ext:Column DataIndex="Web" ColumnID="Web" Header="Web" Editable="false" MenuDisabled="true"
                            Sortable="false" Resizable="false" Width="100" />
                        <ext:Column DataIndex="AssignedTo" ColumnID="AssignedTo" Header="Assigned To" Editable="false"
                            MenuDisabled="true" Sortable="true" Width="100" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
                        <Listeners>
                            <RowSelect Handler="#{HiddenHOCODE}.setValue(this.getSelected().id); " />
                        </Listeners>
                    </ext:RowSelectionModel>
                </SelectionModel>
                <BottomBar>
                    <ext:PagingToolbar ID="MainPageingBar" runat="server" PageSize="100" StoreID="MainStore">
                    </ext:PagingToolbar>
                </BottomBar>
                <DirectEvents>
                    <Command OnEvent="recordEdit" />
                    <RowDblClick OnEvent="recordEdit" />
                </DirectEvents>
                <Listeners>
                    <RowContextMenu Handler="e.preventDefault(); #{RowContextMenu}.showAt(e.getXY());" />
                </Listeners>
            </ext:GridPanel>
        </Items>
    </ext:FitLayout>
    <ext:Window ID="MainWindow" runat="server" Modal="true" Hidden="false" Title="Enquiry Details"
            Layout="fit" Width="1000" Height="600" Resizable="false" Draggable="False">
             <Items>
                <ext:FormPanel ID="MainForm" runat="server" Header="false" Border="false" Title="Application Invitation"
                    MonitorPoll="500"   LabelAlign="Right" ButtonAlign="Left">
                    <Items>
                        <ext:RowLayout ID="RowLayout1" runat="server" Split="false">
                            <Rows>
                                <ext:LayoutRow  >
                                    <ext:Panel ID="Panel4" runat="server" Border="false" Height="215" Header="false" Layout="ColumnLayout" Padding="5">
                                        <Defaults>
                                            <ext:Parameter Name="AllowBlank" Value="false" Mode="Raw" />
                                            <ext:Parameter Name="MsgTarget" Value="side" />
                                        </Defaults>
                                        <Items>
                                            <ext:FieldSet ID="FieldSet2" runat="server"  Title="Prospect"  Height="215"  LabelWidth="70" Layout="Form"  Width="230">
                                                <Items>
                                                    <ext:TextField 
                                                        ID="txtRefNO" 
                                                        runat="server" 
                                                        FieldLabel="Ref No"
                                                        AnchorHorizontal="100%"
                                                         ReadOnly="true"  EmptyText="Auto">
                                                    </ext:TextField>
                                                    <ext:TextField ID="txtProspect" runat="server"  FieldLabel="Prospect" 
                                                    AllowBlank="false" BlankText="Prospect name is required" 
                                                    AnchorHorizontal="100%"/>
                                                    <ext:ComboBox ID="cbSalution"  runat="server"   FieldLabel="Salutation"
                                                    StoreID="StoreSalutation" DisplayField="Name" ValueField="HOCODE"
                                                    TypeAhead="false" Editable="true" HideTrigger="false"
                                                    AllowBlank="false" BlankText="Select Salutation"  AnchorHorizontal="100%">
                                                    </ext:ComboBox>
                                                    <ext:TextField ID="txtFirstName" runat="server" FieldLabel="First Name"
                                                        AnchorHorizontal="100%"   AllowBlank="false" BlankText="First Name is required" />
                                                    <ext:TextField ID="txtLastName" runat="server"   FieldLabel="Last Name"
                                                        AnchorHorizontal="100%"   AllowBlank="false" BlankText="Last Name is required" />
                                                    <ext:DateField ID="txtDate" runat="server" FieldLabel="Date"  AnchorHorizontal="100%"></ext:DateField>
                                                    <ext:CompositeField ID="CompositeField1" runat="server" FieldLabel="Status/Rating" AnchorHorizontal="100%">
                                                        <Items>
                                                            <ext:ComboBox ID="cbStatus" runat="server" FieldLabel="Status" StoreID="StoreSalutation"
                                                                DisplayField="Name" ValueField="HOCODE" TypeAhead="false" AllowBlank="true" BlankText="Select Status"
                                                                  Flex="1">
                                                            </ext:ComboBox>
                                                            <ext:ComboBox ID="cbRating" runat="server" FieldLabel="Rating" StoreID="StoreSalutation"
                                                                DisplayField="Name" ValueField="HOCODE" TypeAhead="false" Editable="true" AllowBlank="false"
                                                                 AnchorHorizontal="100%"  Flex="1">
                                                            </ext:ComboBox>
                                                        </Items>
                                                    </ext:CompositeField>
                                                </Items>
                                            </ext:FieldSet>
                                            <ext:Panel runat="server" ID="panel5"  Width="5"  Border="false"/>
                                            <ext:FieldSet ID="FieldSet1" runat="server" Title="Details"   Height="215"  LabelWidth="60" Layout="ColumnLayout"   ColumnWidth="1">
                                                <Items>
                                                    <ext:Panel runat="server" ID="panel6" Border="false" Height="215" ColumnWidth=".33" LabelWidth="90"  Layout="FormLayout">
                                                        <Items>
                                                            <ext:TextField ID="txtAddressName" runat="server" FieldLabel="Address" AnchorHorizontal="100%"   MaxLength="120"  />
                                                            <ext:TextField ID="txtAddress1" runat="server" FieldLabel="Address 1" AnchorHorizontal="100%"  AllowBlank="false" BlankText="Address 1 is required" MaxLength="120" HideLabel="true" />
                                                            <ext:TextField ID="txtAddress2" runat="server" FieldLabel="Address 2" AnchorHorizontal="100%"   MaxLength="120" HideLabel="true" />
                                                            <ext:TextField ID="txtCity" runat="server" FieldLabel="City/Town" AnchorHorizontal="100%"   MaxLength="120"  />
                                                            <ext:TextField ID="txtState" runat="server" FieldLabel="County/State" AnchorHorizontal="100%"   MaxLength="120"   />
                                                            <ext:TextField ID="txtPostalCode" runat="server" FieldLabel="Zip/Postalcode" AnchorHorizontal="100%" />
                                                            <ext:ComboBox  ID="txtCountry" runat="server" AnchorHorizontal="100%" FieldLabel="Country" ></ext:ComboBox>
                                                        </Items>
                                                    </ext:Panel>
                                                    <ext:Panel runat="server" ID="panel7" Height="215" Border="false" ColumnWidth=".34" LabelWidth="110"  Layout="FormLayout">
                                                         <Items>
                                                            <ext:TextField ID="TextField1" runat="server" FieldLabel="Company Phone" AnchorHorizontal="100%"   MaxLength="20" />
                                                            <ext:TextField ID="TextField2" runat="server" FieldLabel="Direct Phone" AnchorHorizontal="100%"   MaxLength="20"  />
                                                            <ext:TextField ID="TextField3" runat="server" FieldLabel="Company Fax" AnchorHorizontal="100%"   MaxLength="20"  />
                                                            <ext:TextField ID="TextField6" runat="server" FieldLabel="Mobile" AnchorHorizontal="100%"  MaxLength="20" />
                                                            <ext:TextField ID="TextField4" runat="server" FieldLabel="Contact Email" AnchorHorizontal="100%"   MaxLength="120"  />
                                                            <ext:TextField ID="TextField5" runat="server" FieldLabel="Company Email" AnchorHorizontal="100%"   MaxLength="120" />
                                                            <ext:TextField ID="TextField13" runat="server" FieldLabel="Web" AnchorHorizontal="100%"  />
                                                        </Items>
                                                    </ext:Panel>
                                                    <ext:Panel runat="server" ID="panel8" Height="215"  Border="false" ColumnWidth=".33" LabelWidth="110"  Layout="FormLayout">
                                                         <Items>
                                                            <ext:ComboBox  ID="ComboBox1" runat="server" AnchorHorizontal="100%" FieldLabel="Position"   ></ext:ComboBox>
                                                            <ext:ComboBox  ID="ComboBox2" runat="server" AnchorHorizontal="100%" FieldLabel="Department"   ></ext:ComboBox>
                                                             <ext:ComboBox  ID="ComboBox3" runat="server" AnchorHorizontal="100%" FieldLabel="Business"   ></ext:ComboBox>
                                                             <ext:ComboBox  ID="ComboBox4" runat="server" AnchorHorizontal="100%" FieldLabel="Category"   ></ext:ComboBox>
                                                               <ext:TextField ID="TextField7" runat="server" FieldLabel="Enquiry Value" AnchorHorizontal="100%"  />
                                                            <ext:ComboBox  ID="ComboBox6" runat="server" AnchorHorizontal="100%" FieldLabel="Received By"   ></ext:ComboBox>
                                                            <ext:ComboBox  ID="ComboBox5" runat="server" AnchorHorizontal="100%" FieldLabel="Our Rep"   ></ext:ComboBox>
                                                        </Items>
                                                      
                                                    </ext:Panel>
                                                </Items>
                                            </ext:FieldSet>
                                        </Items>
                                    </ext:Panel>
                                </ext:LayoutRow>
                                <ext:LayoutRow RowHeight="1">
                                    <ext:Panel ID="Panel1" runat="server" Layout="ColumnLayout" Border="false" Header="false"
                                        Height="300" LabelAlign="Right">
                                        <Items>
                                            <ext:Panel ID="Panel2" runat="server" Layout="FitLayout" Border="true" Header="false"
                                                LabelAlign="Right" ColumnWidth=".5">
                                                <Items>
                                                    <ext:GridPanel runat="server" ID="GridPanel1" Border="false" StoreID="MainStore"
                                                        StripeRows="true" Title="Notes\Activities\Attachments" TrackMouseOver="true"
                                                        AutoExpandColumn="Details">
                                                        <TopBar>
                                                            <ext:Toolbar ID="Toolbar1" runat="server">
                                                                <Items>
                                                                    <ext:Button ID="Button5" runat="server" Text="Add New" Icon="Add">
                                                                        <Listeners>
                                                                            <Click Handler="#{MainWindow}.show();" />
                                                                        </Listeners>
                                                                    </ext:Button>
                                                                    <ext:Button ID="Button6" runat="server" Text="Edit" Icon="Pencil">
                                                                        <DirectEvents>
                                                                            <Click OnEvent="recordEdit" />
                                                                        </DirectEvents>
                                                                    </ext:Button>
                                                                    <ext:Button ID="Button7" runat="server" Text="Delete" Icon="Delete">
                                                                        <DirectEvents>
                                                                            <Click OnEvent="recordDelete" Success="">
                                                                                <Confirmation ConfirmRequest="true" Message="Are you sure you want to delete?" Title="Confirm Delete" />
                                                                                <EventMask ShowMask="true" Target="Page" Msg="deleting..." />
                                                                            </Click>
                                                                        </DirectEvents>
                                                                    </ext:Button>
                                                                    <ext:ToolbarFill />
                                                                </Items>
                                                            </ext:Toolbar>
                                                        </TopBar>
                                                        <ColumnModel>
                                                            <Columns>
                                                                <ext:RowNumbererColumn />
                                                                <ext:Column DataIndex="HOCODE" ColumnID="HOCODE" Header="HOCODE" Hidden="true" />
                                                                <ext:Column DataIndex="Type" ColumnID="Type" Header="Type" Resizable="false" MenuDisabled="true"
                                                                    Sortable="true" Width="60" />
                                                                <ext:Column DataIndex="CreatedBy" ColumnID="CreatedBy" Header="By" Resizable="false"
                                                                    MenuDisabled="true" Sortable="true" Width="90" />
                                                                <ext:Column DataIndex="Date" ColumnID="Date" Header="Date" MenuDisabled="true" Sortable="false"
                                                                    Width="60">
                                                                    <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y')" />
                                                                </ext:Column>
                                                                <ext:Column DataIndex="Details" ColumnID="Details" Header="Details" Resizable="false"
                                                                    MenuDisabled="true" Sortable="true" Width="160" />
                                                            </Columns>
                                                        </ColumnModel>
                                                        <SelectionModel>
                                                            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                                                                <Listeners>
                                                                    <RowSelect Handler="#{HiddenHOCODE}.setValue(this.getSelected().id); " />
                                                                </Listeners>
                                                            </ext:RowSelectionModel>
                                                        </SelectionModel>
                                                        <DirectEvents>
                                                            <Command OnEvent="recordEdit" />
                                                            <RowDblClick OnEvent="recordEdit" />
                                                        </DirectEvents>
                                                    </ext:GridPanel>
                                                </Items>
                                            </ext:Panel>
                                            <ext:Panel ID="Panel3" runat="server" Layout="FitLayout" Border="true" Padding="5"
                                                Header="true" Title="Requirements" ColumnWidth=".5">
                                                <TopBar>
                                                    <ext:Toolbar ID="Toolbar3" runat="server" Height="28">
                                                    </ext:Toolbar>
                                                </TopBar>
                                                <Items>
                                                    <ext:TextArea ID="txtRequirements" runat="server" HideLabel="true" AllowBlank="false" />
                                                </Items>
                                            </ext:Panel>
                                        </Items>
                                    </ext:Panel>
                                </ext:LayoutRow>
                            </Rows>
                        </ext:RowLayout>
                    </Items>
                </ext:FormPanel>
            </Items>
          <BottomBar>
              <ext:StatusBar ID="FormStatusBar" runat="server" DefaultText="Ready">
                  <Plugins>
                      <ext:ValidationStatus ID="ValidationStatus1" runat="server" FormPanelID="MainForm"
                          ValidIcon="Accept" ErrorIcon="Exclamation" />
                  </Plugins>
              </ext:StatusBar>
          </BottomBar>
          <Buttons>
              <ext:Button ID="Button1" runat="server" Text="Submit" Icon="PackageGo">
                  <DirectEvents>
                      <Click OnEvent="recordSubmit" DisableCaching="false" Success="#{MainForm}.reset();"
                          Before="var valid= #{MainForm}.getForm().isValid(); if (valid) {#{FormStatusBar}.showBusy('Saving...');} return valid;">
                          <EventMask ShowMask="true" Msg="Processing your request..." Target="Page" />
                      </Click>
                  </DirectEvents>
              </ext:Button>
              <ext:Button ID="Button2" runat="server" Text="Close" Icon="Cancel">
                  <Listeners>
                      <Click Handler="#{MainWindow}.hide();" />
                  </Listeners>
              </ext:Button>
          </Buttons>
        </ext:Window>

    Code: UserControl 2
    <%@ Control Language="C#" ClassName="UserControl2" Inherits="BaseUserControl" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void MainStore_OnRefreshData(object sender, DirectEventArgs e)
        {
            
        }
        
        protected void recordNew(object sender, DirectEventArgs e)
        {
             
    
        }
    
        protected void recordEdit(object sender, DirectEventArgs e)
        {
            
        }
        protected void recordDelete(object sender, DirectEventArgs e)
        {
            
        }
        protected void recordSubmit(object sender, DirectEventArgs e)
        {
            
        }
        public override List<string> ControlsToDestroy
        {
            get
            {
                // we should return none lazy controls only because lazy controls will be autodestroyed by parent container
                return new List<string>
                {
    
                };
            }
        }
       
        
    </script>
    
    <ext:Store ID="StoreSalutation" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="HOCODE">
                <Fields>
                    <ext:RecordField Name="HOCODE" />
                    <ext:RecordField Name="Name" />
                    <ext:RecordField Name="Description" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:FitLayout ID="FitLayout1" runat="server">
        <Items> 
            <ext:GridPanel runat="server" ID="MainGrid" Border="false" StripeRows="true"
                Title="Leads " TrackMouseOver="true"   AutoExpandColumn="Name">
                <Store>
                    <ext:Store ID="MainStore" runat="server" AutoSave="false" ShowWarningOnFailure="false">
                        <Reader>
                            <ext:JsonReader IDProperty="HOCODE">
                                <Fields>
                                    <ext:RecordField Name="ApplicationHOCODE" />
                                    <ext:RecordField Name="PartnerHOCODE" />
                                    <ext:RecordField Name="Name" />
                                    <ext:RecordField Name="Description" />
                                    <ext:RecordField Name="IsTrial" Type="Boolean" />
                                    <ext:RecordField Name="StartDate" />
                                    <ext:RecordField Name="ExpiryDate" />
                                    <ext:RecordField Name="LogoURL" />
                                    <ext:RecordField Name="Version" />
                                    <ext:RecordField Name="Monthly" />
                                    <ext:RecordField Name="Yearly" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <TopBar>
                    <ext:Toolbar ID="Toolbar2" runat="server">
                        <Items>
                            <ext:Button ID="Button121" runat="server" Text="Add New" Icon="Add">
                                 <Listeners>
                                    <Click Handler="#{MainWindow}.show();" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="Button332" runat="server" Text="Edit" Icon="Pencil">
                                <DirectEvents>
                                    <Click OnEvent="recordEdit" />
                                </DirectEvents>
                            </ext:Button>
                            <ext:Button ID="Button123" runat="server" Text="Delete" Icon="Delete">
                                <DirectEvents>
                                    <Click OnEvent="recordDelete" Success="">
                                        <Confirmation ConfirmRequest="true" Message="Are you sure you want to delete?" Title="Confirm Delete" />
                                        <EventMask ShowMask="true" Target="Page" Msg="deleting..." />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarFill />
                            <ext:Label runat="server" ID="lblSearch" Text="Search:" />
                            <ext:ToolbarSpacer Width="5" />
                            <ext:ComboBox ID="optFields" SelectedIndex="0" runat="server" Width="180" EmptyText="Select Fields">
                                <Items>
                                    <ext:ListItem Text="Customer" Value="DisplayName" />
                                    <ext:ListItem Text="Application" Value="Name" />
                                    <ext:ListItem Text="Description" Value="Description" />
                                </Items>
                            </ext:ComboBox>
                            <ext:ToolbarSpacer Width="5" />
                            <ext:TriggerField ID="optQueryString" runat="server" Width="240">
                                <Triggers>
                                    <ext:FieldTrigger Icon="Clear" Qtip="<b>Clear</b><br/>Click to clear" />
                                    <ext:FieldTrigger Icon="Search" Qtip="<b>Search</b><br/>Click to search" />
                                </Triggers>
                                <Listeners>
                                    <TriggerClick Handler="
                                        if(index==0){#{optQueryString}.clear(); #{MainStore}.filter(#{optFields}.getValue(),'',true,false);}
                                        if(index==1){#{MainStore}.filter(#{optFields}.getValue(),#{optQueryString}.getValue(),true,false);} " />
                                </Listeners>
                            </ext:TriggerField>
                            <ext:ToolbarSpacer Width="5" />
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column DataIndex="HOCODE" ColumnID="HOCODE" Header="HOCODE" Hidden="true" />
                        <ext:Column DataIndex="Type" ColumnID="Type" Header="Type" Resizable="false" MenuDisabled="true"
                            Sortable="true" Width="100" />
                        <ext:Column DataIndex="Name" ColumnID="Name" Header="Name" Resizable="false" MenuDisabled="true"
                            Sortable="true" Width="180" />
                        <ext:Column DataIndex="FullAddress" ColumnID="FullAddress" Header="Full Address"
                            Resizable="false" MenuDisabled="true" Sortable="false" Width="220" />
                        <ext:Column DataIndex="CreatedDate" ColumnID="CreatedDate" Header="Created Date"
                            MenuDisabled="true" Sortable="false" Width="80">
                            <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y')" />
                        </ext:Column>
                        <ext:Column DataIndex="Phone" ColumnID="Phone" Header="Phone" Editable="false" MenuDisabled="true"
                            Sortable="false" Resizable="false" Width="80" />
                        <ext:Column DataIndex="Web" ColumnID="Web" Header="Web" Editable="false" MenuDisabled="true"
                            Sortable="false" Resizable="false" Width="100" />
                        <ext:Column DataIndex="AssignedTo" ColumnID="AssignedTo" Header="Assigned To" Editable="false"
                            MenuDisabled="true" Sortable="true" Width="100" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
                        <Listeners>
                            <RowSelect Handler="#{HiddenHOCODE}.setValue(this.getSelected().id); " />
                        </Listeners>
                    </ext:RowSelectionModel>
                </SelectionModel>
                <BottomBar>
                    <ext:PagingToolbar ID="MainPageingBar" runat="server" PageSize="100" StoreID="MainStore">
                    </ext:PagingToolbar>
                </BottomBar>
                <DirectEvents>
                    <Command OnEvent="recordEdit" />
                    <RowDblClick OnEvent="recordEdit" />
                </DirectEvents>
                <Listeners>
                    <RowContextMenu Handler="e.preventDefault(); #{RowContextMenu}.showAt(e.getXY());" />
                </Listeners>
            </ext:GridPanel>
        </Items>
    </ext:FitLayout>
    <ext:Window ID="MainWindow" runat="server" Modal="true" Hidden="false" Title="Enquiry Details"
            Layout="fit" Width="1000" Height="600" Resizable="false" Draggable="False">
            <Items>
                 <ext:FormPanel ID="MainForm" runat="server" Header="false" Border="false" Title="Prospect Details"
                MonitorPoll="500" Layout="FitLayout" Padding="5" LabelWidth="100" Frame="true"
                ButtonAlign="Left">
                <Items>
                    <ext:Container ID="Container1" runat="server" Layout="Column" Height="300">
                        <Items>
                            <ext:Container ID="Container2" runat="server" Layout="Form" ColumnWidth=".5">
                                <Items>
                                    <ext:TextField ID="txtProspect" runat="server" FieldLabel="Prospect" AllowBlank="false"
                                        BlankText="Prospect name is required" AnchorHorizontal="92%">
                                    </ext:TextField>
                                    <ext:ComboBox ID="cbSalution" runat="server" FieldLabel="Salutation" StoreID="StoreSalutation"
                                        DisplayField="Name" ValueField="HOCODE" TypeAhead="false" Editable="true" HideTrigger="false"
                                        AllowBlank="false" BlankText="Select Salutation" AnchorHorizontal="92%">
                                    </ext:ComboBox>
                                    <ext:TextField ID="txtFirstName" runat="server" FieldLabel="First Name" AnchorHorizontal="92%"
                                        AllowBlank="false" BlankText="First Name is required">
                                    </ext:TextField>
                                    <ext:TextField ID="txtLastName" runat="server" FieldLabel="Last Name" AnchorHorizontal="92%"
                                        AllowBlank="false" BlankText="Last Name is required">
                                    </ext:TextField>
                                    <ext:DateField ID="txtDate" runat="server" FieldLabel="Date" AnchorHorizontal="92%">
                                    </ext:DateField>
                                    <ext:ComboBox ID="cbStatus" runat="server" FieldLabel="Status" StoreID="StoreSalutation"
                                        DisplayField="Name" ValueField="HOCODE" TypeAhead="false" AllowBlank="true" BlankText="Select Status"
                                        AnchorHorizontal="92%">
                                    </ext:ComboBox>
                                    <ext:ComboBox ID="cbRating" runat="server" FieldLabel="Rating" StoreID="StoreSalutation"
                                        DisplayField="Name" ValueField="HOCODE" TypeAhead="false" Editable="true" AllowBlank="false"
                                        AnchorHorizontal="92%">
                                    </ext:ComboBox>
                                </Items>
                            </ext:Container>
                            <ext:Container ID="Container3" runat="server" Layout="Form" ColumnWidth=".5">
                                <Items>
                                    <ext:TextField ID="TextField1" runat="server" FieldLabel="Company Phone" AnchorHorizontal="100%"
                                        MaxLength="20" />
                                    <ext:TextField ID="TextField2" runat="server" FieldLabel="Direct Phone" AnchorHorizontal="100%"
                                        MaxLength="20" />
                                    <ext:TextField ID="TextField3" runat="server" FieldLabel="Company Fax" AnchorHorizontal="100%"
                                        MaxLength="20" />
                                    <ext:TextField ID="TextField6" runat="server" FieldLabel="Mobile" AnchorHorizontal="100%"
                                        MaxLength="20" />
                                    <ext:TextField ID="TextField4" runat="server" FieldLabel="Contact Email" AnchorHorizontal="100%"
                                        MaxLength="120" />
                                    <ext:TextField ID="TextField5" runat="server" FieldLabel="Company Email" AnchorHorizontal="100%"
                                        MaxLength="120" />
                                    <ext:TextField ID="TextField13" runat="server" FieldLabel="Web" AnchorHorizontal="100%" />
                                </Items>
                            </ext:Container>
                        </Items>
                    </ext:Container>
                </Items>
              
            </ext:FormPanel>
            </Items>
          <BottomBar>
              <ext:StatusBar ID="FormStatusBar" runat="server" DefaultText="Ready">
                  <Plugins>
                      <ext:ValidationStatus ID="ValidationStatus1" runat="server" FormPanelID="MainForm"
                          ValidIcon="Accept" ErrorIcon="Exclamation" />
                  </Plugins>
              </ext:StatusBar>
          </BottomBar>
          <Buttons>
              <ext:Button ID="Button1" runat="server" Text="Submit" Icon="PackageGo">
                  <DirectEvents>
                      <Click OnEvent="recordSubmit" DisableCaching="false" Success="#{MainForm}.reset();"
                          Before="var valid= #{MainForm}.getForm().isValid(); if (valid) {#{FormStatusBar}.showBusy('Saving...');} return valid;">
                          <EventMask ShowMask="true" Msg="Processing your request..." Target="Page" />
                      </Click>
                  </DirectEvents>
              </ext:Button>
              <ext:Button ID="Button2" runat="server" Text="Close" Icon="Cancel">
                  <Listeners>
                      <Click Handler="#{MainWindow}.hide();" />
                  </Listeners>
              </ext:Button>
          </Buttons>
        </ext:Window>
    Code : BaseUserControl
    using System.Collections.Generic;
    using System.Web.UI;
    
    public class BaseUserControl : UserControl
    {
        public virtual List<string> ControlsToDestroy
        {
            get
            {
                // we should return none lazy controls only because lazy controls will be autodestroyed by parent container
                return new List<string>();
            }
        }
    }

    I also tried to destroy controls on List<string> ControlsToDestroy, didn't help

    Code Sample
      public override List<string> ControlsToDestroy
        {
            get
            {
                // we should return none lazy controls only because lazy controls will be autodestroyed by parent container
                return new List<string>
                           {
                               this.txtAddress1.ClientID, 
                               this.txtAddress2.ClientID, 
                               this.txtAddressName.ClientID, 
                               this.txtCity.ClientID, 
                               this.txtCountry.ClientID, 
                               this.txtDate.ClientID, 
                               this.txtFirstName.ClientID, 
                               this.txtLastName.ClientID
                               
                           };
            }
        }
    Sorry for long code I couldn't attached the project files or zip from attachments
    Last edited by Daniil; Jun 28, 2011 at 11:24 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please try to add CloseAction="Close" for the Window.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Please try to add CloseAction="Close" for the Window.
    Thanks Daniil,


    I did it still same problem...
  4. #4
    O, I need to run your code to reproduce the problem.

    Please reduce the code as much as you can using this technique:
    How to reduce a sample
  5. #5
    Quote Originally Posted by Daniil View Post
    O, I need to run your code to reproduce the problem.

    Please reduce the code as much as you can using this technique:
    How to reduce a sample
    got it now...
  6. #6
    Quote Originally Posted by Daniil View Post
    O, I need to run your code to reproduce the problem.

    Please reduce the code as much as you can using this technique:
    How to reduce a sample

    Thanks Daniil

    follow the rules I got the fix

    problem was on close button I was using #{MainWindow}.hide(); according to your suggestion I should close window
    Code :
    <ext:Button ID="Button2" runat="server" Text="Close" Icon="Cancel">
           <Listeners>
             <Click Handler="#{MainWindow}.hide();" />
       </Listeners>
    </ext:Button>
    But It cause another issue how to open windows again on AddNew ?
    Code
     <ext:Button ID="Button121" runat="server" Text="Add New" Icon="Add">
        <Listeners>
              <Click Handler="#{MainWindow}.show();" />
        </Listeners>
      </ext:Button>
  7. #7
    win.close()
    destroys the Window.

    You need to render it again.
  8. #8
    Thanks Mark as solved

Similar Threads

  1. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  2. [CLOSED] Multiple User Controls problem
    By CMA in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 12, 2011, 12:38 PM
  3. Replies: 8
    Last Post: Jan 25, 2011, 4:21 AM
  4. Replies: 8
    Last Post: Jun 24, 2010, 9:39 PM
  5. Replies: 3
    Last Post: May 11, 2010, 10:36 AM

Tags for this Thread

Posting Permissions