[CLOSED] Adding aspx Gridpanel to dynamically created tab

  1. #1

    [CLOSED] Adding aspx Gridpanel to dynamically created tab

    Hi Daniil, I'd like to ask about the possibility of adding gridpanel (or the entire form with gridpanel) to dynamically created tab. Gridpanel is created using aspx mark up language. Tabs are created as follows:

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!this.IsPostBack && !X.IsAjaxRequest)
                {
                    // Get tabs for current report 
                    System.Data.SqlClient.SqlConnection myConnection = new     System.Data.SqlClient.SqlConnection(aSecureWEBGlobals.GetConnectionString("asa"));
                    String strUsrId = (String)Session["UsrId"];
                    int intReportId = 1; // Priste brat z parametru volani Page
                    String strSqlCommand = "asg_GetReportSelectTabsToReport '" + strUsrId + "', " + intReportId + ", " + Session["LanguageId"].ToString();
                    SqlCommand myCommand = new SqlCommand(strSqlCommand, myConnection);
                    SqlDataReader myReader = default(SqlDataReader);
    
                    myConnection.Open();
                    myReader = myCommand.ExecuteReader();
    
                    // For every record create appropriate tab and grid with multiple select column
                    while (myReader.Read())
                    {
                        Int32 strTabID = myReader.GetInt32(0);
                        String strTabName = myReader.GetString(1);
                        String strTabTitle = myReader.GetString(2);
                        CreateTab(tpReportSelectTabs, strTabName, strTabTitle);
                    }
                    tpReportSelectTabs.ActiveTabIndex = 1;
                }
            }
    
            private void CreateTab(TabPanel theTabPanel, String strTabName, String strTabTitle)
            {
                Ext.Net.Panel tab = new Ext.Net.Panel();
                tab.ID = strTabName;
                tab.Title = strTabTitle;
                tab.Closable = false; 
                theTabPanel.Add(tab);
            }
    Empty tabpanel is:

    <body>
    
        <form id="Form1" runat="server">
    
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
            <ext:TabPanel ID="tpReportSelectTabs" runat="server" Border="true" Height="600">
            </ext:TabPanel>
    
          </form>
    
    </body>
    Another question, if is it possible, where I should place aspx code with predefined gridpanel. Or for this purpose I should create whole gridapanel also dynamically in code behind (or JS) ? Thanks. ASAPCH
    Last edited by Daniil; Dec 12, 2012 at 12:27 PM. Reason: [CLOSED]
  2. #2
    Hi @ASAPCH,

    You can put the GridPanel into a user control.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @ASAPCH,

    You can put the GridPanel into a user control.
    Hi Daniil, thanks for reply. I have create 2 user controls with GridPanel and tried to put it to two Tabs in TabPanel by following:

    <%@ Register src="PersonSelect.ascx" tagname="PersonSelect" tagprefix="uc1" %>
    <%@ Register src="ZoneSelect.ascx" tagname="ZoneSelect" tagprefix="uc1" %>
    .....
    <ext:TabPanel ID="tpReportSelectTabs" runat="server" Border="true" Height="600">
            <Items>
              <ext:FormPanel 
                    ID="formpanelPerson" 
                    runat="server" 
                    Title="Persons"
                    Icon="User"
                    DefaultAnchor="100%"
                    BodyPadding="5"
                    Frame="true"
                    >
                       <Items>
                            <uc1:PersonSelect ID="PersonSelect1" runat="server" />
                       </Items>
               </ext:FormPanel>
                    
               <ext:FormPanel 
                    ID="formpanelZones" 
                    runat="server" 
                    Title="Zones"
                    Icon="Building"
                    DefaultAnchor="100%"
                    BodyPadding="5"
                    >
                      <Items>
                            <uc1:ZoneSelect ID="ZoneSelect1" runat="server" />
                      </Items>
              </ext:FormPanel>
            </Items>
            </ext:TabPanel>
    But I have obtained error:Parser Error Message: Ext.Net.ItemsCollection`1[[Ext.Net.AbstractComponent, Ext.Net, Version=2.1.0.41016, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87]] must have items of type 'Ext.Net.AbstractComponent'. 'uc1:PersonSelect' is of type 'ASP.modules_asg_personselect_ascx'.
    Can you tell me,how can I use this user control in aspx Tab resp. how to insert it into Tab also from code behind.
    If I use this user control in page,it works:
    <form id="Form1" runat="server">
         <ext:ResourceManager ID="ResourceManager1" runat="server" />
         <uc1:ZoneSelect ID="ZoneSelect1" runat="server" /> 
     </form>
    Thank you for help. ASAPCH
    Last edited by ASAPCH; Dec 04, 2012 at 10:51 PM.
  4. #4
    Hello!

    In Items collection you can put only instances of Ext.Net.AbstractComponent.

    If you want to put inside a container something different like UserControl you can use Content colletion:

    <ext:FormPanel
    		ID="formpanelZones"
    		runat="server"
    		Title="Zones"
    		Icon="Building"
    		DefaultAnchor="100%"
    		BodyPadding="5"
    		>
    		  <Content>
    				<uc1:ZoneSelect ID="ZoneSelect1" runat="server" />
    		  </Content>
      </ext:FormPanel>
  5. #5
    Quote Originally Posted by Baidaly View Post
    Hello!

    In Items collection you can put only instances of Ext.Net.AbstractComponent.

    If you want to put inside a container something different like UserControl you can use Content colletion:

    <ext:FormPanel
    		ID="formpanelZones"
    		runat="server"
    		Title="Zones"
    		Icon="Building"
    		DefaultAnchor="100%"
    		BodyPadding="5"
    		>
    		  <Content>
    				<uc1:ZoneSelect ID="ZoneSelect1" runat="server" />
    		  </Content>
      </ext:FormPanel>
    Hello, that's right, I forgot.. but now I have got error message:"Control with type 'Ext.Net.XScript' cannot be handled by layout". Yes,inside user control Ext.Net.XScript was used. After removing it new error is: Control with type 'System.Web.UI.WebControls.SqlDataSource' cannot be handled by layout... Last question is, how to insert this user control into Tab from code behind "dynamically" inside function: private void CreateTab(TabPanel theTabPanel, String strTabName, String strTabTitle) as described at the top of thread.Thanks. ASAPCH
    Last edited by ASAPCH; Dec 05, 2012 at 8:38 AM.
  6. #6
    Please use the HtmlBin property. Here is an example.
    https://examples2.ext.net/#/Miscella...n/UserControl/
  7. #7
    Quote Originally Posted by Daniil View Post
    Please use the HtmlBin property. Here is an example.
    https://examples2.ext.net/#/Miscella...n/UserControl/
    Hi,Daniil, I would like to ask you to solve following problem. At least I add user control to tab dynamically:

      private void CreateTab(TabPanel theTabPanel, String strTabName, String strTabTitle, Int32 ReportId)
            {
              
                Ext.Net.Panel tab = new Ext.Net.Panel();
                tab.ID = strTabName;
                tab.Title = strTabTitle;
                tab.Closable = false;
                if (strTabName == "Zones")
                 {
                     aSecureWEB.Modules.asg.ZoneSelect uc1 = (aSecureWEB.Modules.asg.ZoneSelect)this.LoadControl("ZoneSelect.ascx");
                     uc1.ID = "ZoneSelect1";
                     uc1.ReportId = ReportId;
                     tab.ContentControls.Add(uc1);
                 }
                else if (strTabName == "Readers")
                {
                    aSecureWEB.Modules.asg.ReaderSelect uc1 = (aSecureWEB.Modules.asg.ReaderSelect)this.LoadControl("ReaderSelect.ascx");
                    uc1.ID = "ReaderSelect1";
                    uc1.ReportId = ReportId;
                    tab.ContentControls.Add(uc1);
                }.......
    Inside user control ReaderSelect1 is button :
    <ext:Button ID="buttonAddSelected" runat="server" Text="Add selected" Disabled="true" ToolTip="Add selected Readers " Icon="PageGo" > 
                        <DirectEvents>
                            <Click OnEvent="buttonAddSelected_Click"  />
                        </DirectEvents>
                        <%--<Listeners>
                            <Click Handler="addSelectedReaders ( #{gridpanelReader} );" />
                        </Listeners>--%>
                    </ext:Button>
    User control with gird and button is rendered OK,but after click on buttonAddSelected,I got error message:
    The control with ID 'ReaderSelect1_buttonAddSelected' not found ... by ResourceManager.
    Also if I call DirectMethod from script I get message ReaderSelect1 control not found. Can you help me?. Thanks. ASAPCH
  8. #8
    A DirectEvent handler requires a control instance on a server as common ASP.NET events.

    You create the user control with the Button during one request, but don't recreate during another when a DirectEvent actually fires.

    There are two possible approaches:

    1. Recreate the controls during each request.
    2. Use a Listener + DirectMethod combination.

    I would prefer the second one.
    Last edited by Daniil; Dec 06, 2012 at 2:50 PM.

Similar Threads

  1. [CLOSED] Adding a dynamically created textfield below fileuploadfield
    By wisdomchuck in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 29, 2012, 4:09 PM
  2. Replies: 2
    Last Post: Mar 22, 2012, 12:49 PM
  3. Replies: 8
    Last Post: Mar 13, 2012, 5:54 PM
  4. Replies: 3
    Last Post: Mar 30, 2010, 1:03 PM
  5. Replies: 2
    Last Post: Nov 25, 2009, 8:35 AM

Tags for this Thread

Posting Permissions