[CLOSED] How to change and save Portal control's content ??

  1. #1

    [CLOSED] How to change and save Portal control's content ??

    I want to dynamic add Portal control's content .
    But I encountered two problems.

    1)When PortletReSet mehtod executed, the Portal control's content does not change?

    2)In PortletSave method, the portal.Items is empty?

    Help!!!

    aspx:
     <ext:Portal ID="PortalMain" runat="server" Border="false"   >
       </ext:Portal>
    
    <ext:Button runat="server" ID="BtnResetPorlet" Text="reset Width="70">
                                            <DirectEvents>
                                                <Click OnEvent="PortletReSet"></Click>
                                            </DirectEvents>
        </ext:Button>
        
      <ext:Button runat="server" ID="BtnSavePortlet" Text="save" Width="70">
                                            <DirectEvents>
                                                <Click OnEvent="PortletSave"></Click>
                                            </DirectEvents>
        </ext:Button>
    cs code:
       protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                BindPortelet("10");
            }
        }
    
      private void BindPortelet(string columnIndex)
        {
           PortalMain.Items.Clear();
           PortalColumn tempcolumn = new PortalColumn();
            tempcolumn.ID = "column" + columnIndex ;
    
                     Portlet templet = new Portlet();
                    templet.ID = "p1";
                    templet.Title = "p1"
                   
                    tempcolumn.Items.Add(templet);
    
            PortalMain.Items.Add(tempcolumn);
            
          
            PortalMain.DataBind();
            PortalMain.DoLayout();
        }
    
    
      protected void PortletReSet (object sender, DirectEventArgs e)
        {  
             BindPortelet("200"); 
        }
    
    
    
    // portal.Items  is empty, count=0?
     protected void  PortletSave (object sender, DirectEventArgs e)
        {
            string ids = "";
    
            foreach (Portal portal in ControlUtils.FindControls<Portal>(this.Page))
            {
                foreach (PortalColumn tempcolumn in  portal.Items )
                {
                    foreach (Portlet tempportlet in tempcolumn.Items)
                    {
                          ids += tempportlet.ID + ",";
                    }
                }
            }
           
        }
    Last edited by Daniil; Aug 19, 2013 at 7:55 AM. Reason: [CLOSED]
  2. #2
    Hi @wangyi,

    Quote Originally Posted by wangyi View Post
    1)When PortletReSet mehtod executed, the Portal control's content does not change?
    To render a control dynamically during a DirectEvent, you should render it manually. I.e. it is not enough to add a control to a container's Items and call a container's DoLayout or DataBind methods. By the way, you can remove the last two.

    In your scenario, i.e. adding PortalColumn dynamically, I can suggest to re-render an entire Portal if it is an appropriate option.

    Example

    private void BindPortelet(string columnIndex)
    {
        PortalMain.Items.Clear();
        PortalColumn tempcolumn = new PortalColumn();
        tempcolumn.ID = "column" + columnIndex;
    
        Portlet templet = new Portlet();
        templet.ID = "p1";
        templet.Title = "p1";
    
        tempcolumn.Items.Add(templet);
        PortalMain.Items.Add(tempcolumn);
    
        if (X.IsAjaxRequest)
        {
            PortalMain.Render();
        }
    }
    To do not lose the Portal's position on the page, please wrap it in an Ext.NET Container.

    Quote Originally Posted by wangyi View Post
    2)In PortletSave method, the portal.Items is empty?
    If you create something during one DirectEvent, it is not automatically recreated (neither by Ext.NET or ASP.NET) during another DirectEvent. So, if you need to access all the dynamically added Items you should recreate them during each request. Though, it might get complicated. So, can you clarify why do you need it? To render something into a Portlet. If so, please take a look at this example.
    https://examples2.ext.net/#/XRender/..._Add_Children/
  3. #3

    Thanks.

    Thanks for help!

Similar Threads

  1. Save/Load Portal state
    By zbarbasinski in forum 1.x Help
    Replies: 0
    Last Post: Aug 13, 2009, 4:43 AM
  2. Replies: 3
    Last Post: Jul 14, 2009, 9:47 PM
  3. How to Save Grid Content
    By nanosassa in forum 1.x Help
    Replies: 1
    Last Post: May 09, 2009, 12:29 PM
  4. Replies: 2
    Last Post: Jan 20, 2009, 11:21 AM
  5. [CLOSED] Create Stateful Portal - Save Position and Collapse of Portlets
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 16, 2008, 7:26 PM

Tags for this Thread

Posting Permissions