Merge mode dynamic control creation

  1. #1

    Merge mode dynamic control creation

    In this scenario https://examples1.ext.net/#/Panel/Ba...oad_MergeMode/ when you create a dynamically Ext.Combobox there is no way to get selectedItem value/text from it. It seems it has some issue on the control state
    Example bellow is from child.aspx.Calling this page from parent.aspx in merge mode selectedItem.value is alaways null.Bellow example works fine if it is called by itself

    protected void Page_Load(object sender, EventArgs e){
                Ext.Net.ComboBox cbo1 = new Ext.Net.ComboBox();
                cbo1.FieldLabel = "Cities";
                cbo1.Width = new Unit("200px");
                cbo1.Items.Add(new Ext.Net.ListItem("Nicosia", "Nicosia"));
                cbo1.Items.Add(new Ext.Net.ListItem("Athens", "Athens"));
                cbo1.ID = "cbo1";
                cbo1.SelectedIndex = 0;
    
                this.Panel2.Items.Add(cbo1);
            }
    
            protected void UpdateTimeStamp(object sender, DirectEventArgs e)
            {
                Ext.Net.ComboBox cbo1 = (Ext.Net.ComboBox)this.Panel2.FindControl("cbo1");
                X.Msg.Notify("The selected City: ", cbo1.SelectedItem.Text).Show();
    
    
            }
    any Ideas ??
    and how can i do line numbering??
    Last edited by zeus; Dec 13, 2011 at 5:47 PM.
  2. #2
    Hi,

    When using MergeMode, the Parent will not have any access to instances of Controls on the Child.

    If you would like to get input field values of Child Controls (in the Parent), you can fetch values directly from the Request object.

    Example

    this.Request.Form["ComboBox1"]
    Hope this helps.

    p.s. For future posts, please wrap your code samples in [CODE] tags. This is automatically created formatted code, and line numbering of your code samples.
    Geoffrey McGill
    Founder
  3. #3
    Quote Originally Posted by geoffrey.mcgill View Post
    Hi,

    When using MergeMode, the Parent will not have any access to instances of Controls on the Child.

    If you would like to get input field values of Child Controls (in the Parent), you can fetch values directly from the Request object.

    Example

    this.Request.Form["ComboBox1"]
    Hope this helps.

    p.s. For future posts, please wrap your code samples in [CODE] tags. This is automatically created formatted code, and line numbering of your code samples.
    thank you very much for your replay.
    But Unfortunately the scenario I have demands dynamic control creation.So the only option i have is to use iframes.
    The problem with iframes is that each frame loads its own copy of Ext.js so if you open 5 tabs with iframes the page size becomes very big.
    what scenario should I choose to resemble somehow MasterPages behavior?? I don't want to put everything in one aspx file.
  4. #4
    Quote Originally Posted by zeus View Post
    So the only option i have is to use iframes.
    Why? Why not MergeMode?

    You are right that you don't want to use iframes - it's fairly heavy-weight, especially for IE.

    And, repeat myself, I still don't understand why you can't use Merge mode.

    Also I would recommend to consider rendering controls dynamically:
    https://examples1.ext.net/#/XRender/..._Add_Children/
    and implementing custom controls.
  5. #5
    Quote Originally Posted by Daniil View Post
    Why? Why not MergeMode?

    You are right that you don't want to use iframes - it's fairly heavy-weight, especially for IE.

    And, repeat myself, I still don't understand why you can't use Merge mode.

    Also I would recommend to consider rendering controls dynamically:
    https://examples1.ext.net/#/XRender/..._Add_Children/
    and implementing custom controls.
    Well when you create dynamically control on child.aspx you can?t get its state as in the example above.
    The scenario is following. I have main.aspx which has a treeMenu in which some of the leaf nodes triggers to open a new tab the tab panel loads Reports.aspx in Merge mode. The ?Reports.aspx? according to some params creates dynamically controls, but the problem is if user modifies control value you cannot have its value from Reports.aspx. Yes I know you can get it from parent as mentioned by ?geoffrey.mcgill? but this would not be solution I want. Since it would make the handling of user option from main.aspx .
    Try this yourself
    https://examples1.ext.net/#/Panel/Basi...oad_MergeMode/
    Just add additional code in PageLoad in child.aspx
    protected void Page_Load(object sender, EventArgs e){
                Ext.Net.ComboBox cbo1 = new Ext.Net.ComboBox();
                cbo1.FieldLabel = "Cities";
                cbo1.Width = new Unit("200px");
                cbo1.Items.Add(new Ext.Net.ListItem("Nicosia", "Nicosia"));
                cbo1.Items.Add(new Ext.Net.ListItem("Athens", "Athens"));
                cbo1.ID = "cbo1";
                cbo1.SelectedIndex = 0;
     
                this.Panel2.Items.Add(cbo1);
            }
    //and here button directevent
    protected void btnClick(object sender, DirectEventArgs e)
            {
                Ext.Net.ComboBox cbo1 = (Ext.Net.ComboBox)this.Panel2.FindControl("cbo1");
                X.Msg.Notify("The selected City: ", cbo1.SelectedItem.Text).Show();
     
     
            }
    SelectedItem.Value is always null:(((
  6. #6
    Thanks for the details.

    Well, it can work if ViewState is disabled at all on both pages.

    Example Parent Page
    <%@ 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">
    <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" DisableViewState="true" />
            <ext:Panel runat="server">
                <AutoLoad Mode="Merge" Url="Child.aspx" />
            </ext:Panel>
        </form>
    </body>
    </html>
    Example Child Page
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void GetValue(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Value", this.ComboBox1.SelectedItem.Value).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>
        <ext:ResourceManager runat="server" RenderScripts="None" DisableViewState="true" />
        <ext:ComboBox ID="ComboBox1" runat="server">
            <Items>
                <ext:ListItem Text="Item 1" Value="1" />
                <ext:ListItem Text="Item 2" Value="2" />
            </Items>
            <SelectedItem Value="1" />
        </ext:ComboBox>
        <ext:Button runat="server" Text="Get value">
            <DirectEvents>
                <Click OnEvent="GetValue" Url="Child.aspx" Type="Submit" />
            </DirectEvents>
        </ext:Button>
    </body>
    </html>
    Generally speaking, we always recommend to don't use and disable ViewState when someone asks us how to improve application performance.

    So, I think this would be a good solution if, certainly, you can disable ViewState.
  7. #7

    Merge mode

    Thank you Daniil. The example you have provided works . However have you notices that merge mode in .Net 3.5 behaves completely differently than .Net4.0 ?
    Just try it and you will see that in .Net 4.0 it allows actually to load second Form In other world in both Parent.aspx and child aspx you can have
    <form runat="server" id="formChild" ></from>
    Saying that I stuck in other issue. Lets say we have the following code in child.aspx
     btnReload.DirectEvents.Click.Event += reloadGrid;
     btnReload.DirectEvents.Click.Url = "ReportFactory.aspx?ReportID=" + reportId.ToString();
     
    
    
     protected void reloadGrid(object sender, DirectEventArgs e) 
    {
     DataTable dt = this.getDateTable();
     this.grdStore.DataSource = dt;
     this.grdStore.DataBind();
     grdPanel.LoadMask.ShowMask = true;
     grdPanel.LoadMask.Msg = "Loading";
    }
    The code above works just fine but I was unable to show loading mask on the grid .
    The only option so far I found is
    btnReload.DirectEvents.Click.EventMask.ShowMask = true;
    btnReload.DirectEvents.Click.EventMask.Target = MaskTarget.Page;
    How can I trigger Grids Mask ???
  8. #8
    Quote Originally Posted by zeus View Post
    Thank you Daniil. The example you have provided works . However have you notices that merge mode in .Net 3.5 behaves completely differently than .Net4.0 ?
    Just try it and you will see that in .Net 4.0 it allows actually to load second Form In other world in both Parent.aspx and child aspx you can have
    <form runat="server" id="formChild" ></from>
    Not sure that I understand the problem well.

    Is the problem reproducible with my example?

    Please provide more details.<form runat="server" id="formChild" ></from>
    Saying that I stuck in other issue. Lets say we have the following code in child.aspx
     btnReload.DirectEvents.Click.Event += reloadGrid;
     btnReload.DirectEvents.Click.Url = "ReportFactory.aspx?ReportID=" + reportId.ToString();
     
    protected void reloadGrid(object sender, DirectEventArgs e) 
    {
     DataTable dt = this.getDateTable();
     this.grdStore.DataSource = dt;
     this.grdStore.DataBind();
     grdPanel.LoadMask.ShowMask = true;
     grdPanel.LoadMask.Msg = "Loading";
    }
    The code above works just fine but I was unable to show loading mask on the grid .
    The only option so far I found is
    btnReload.DirectEvents.Click.EventMask.ShowMask = true;
    btnReload.DirectEvents.Click.EventMask.Target = MaskTarget.Page;
    How can I trigger Grids Mask ???
    The issue is not related to Merge mode at all. You will get the same result in a common single aspx.

    So, please start a new forum thread for that issue.
    Last edited by Daniil; Jan 12, 2012 at 8:33 AM.

Similar Threads

  1. Grids reload in Merge mode
    By zeus in forum 1.x Help
    Replies: 0
    Last Post: Jul 05, 2012, 7:10 AM
  2. Replies: 13
    Last Post: Jan 23, 2012, 9:37 AM
  3. merge mode refresh
    By testix in forum 1.x Help
    Replies: 1
    Last Post: Jan 10, 2011, 2:03 PM
  4. Replies: 0
    Last Post: Jun 16, 2010, 6:18 AM
  5. AutoLoad Merge Mode Issue with IE
    By geniusCoder in forum 1.x Help
    Replies: 1
    Last Post: Nov 05, 2009, 11:53 AM

Tags for this Thread

Posting Permissions