Positioning control from codebehind

  1. #1

    Positioning control from codebehind

    Hi,

    I'm building an UI Engine and I have an issue. I'm not able to positioning both label field an textbox of a TextField at specified coordinates.

    Please may you help me?

    Cheers

    namespace ui
    {
        public enum eUIObject
        {
            FormPanel,
            TextField,
            Button
        }
    
        public class SYS_UIOBJECTS
        {
            public eUIObject ControlType { get; set; }
            public string Parent { get; set; }
            public string ID { get; set; }
            public int X { get; set; }
            public int Y { get; set; }
        }
    
        public class UIEngine : System.Web.UI.Page
        {
            List<SYS_UIOBJECTS> m_pageComponents;
    
            public UIEngine(int CodePage)
            {
                if (CodePage == 0)
                {
                    m_pageComponents = new List<SYS_UIOBJECTS>()
                    {
                        new SYS_UIOBJECTS() { ControlType= eUIObject.FormPanel,       Parent="",      ID="pnl1"},
                        new SYS_UIOBJECTS() { ControlType= eUIObject.TextField,   Parent="pnl1",  ID="UserName",       X=10, Y=30},
                        new SYS_UIOBJECTS() { ControlType= eUIObject.TextField,   Parent="pnl1",  ID="UserPassword",   X=10, Y=100},
                        
                        //new SYS_UIOBJECTS() { ControlType= eUIObject.Panel,       Parent="",      ID="pnl2"},
                        //new SYS_UIOBJECTS() { ControlType= eUIObject.Button,      Parent="pnl2",  ID="Login",          X=10, Y=200}
                    };
                }
            }
    
            internal void BuildUI()
            {
                base.Controls.Add(new ResourceManager() { Theme = Ext.Net.Theme.Access });
    
                FormPanel current_container = null;
    
                for (int i = 0; i < m_pageComponents.Count; i++)
                {
                    SYS_UIOBJECTS ctl = m_pageComponents.ElementAt(i);
    
                    switch (ctl.ControlType)
                    {
                        case eUIObject.FormPanel:
                            if (current_container != null)
                                base.Controls.Add(current_container);
    
                            current_container = new FormPanel() { ID = ctl.ID, Width=300, Height=200, Title = "Test text", MonitorResize=true };
                            break;
    
                        case eUIObject.TextField:
                            TextField tf = new TextField() { Text = "tb test", FieldLabel = "label", ID = ctl.ID, X = ctl.X, Y = ctl.Y };
    
                            if (current_container != null)
                                current_container.Items.Add(tf);
                            else
                                base.Controls.Add(tf);
                            break;
    
                        case eUIObject.Button:
                            Button b = new Button() { Text = "b test", ID = ctl.ID };
    
                            if (current_container != null)
                                current_container.Items.Add(b);
                            else
                                base.Controls.Add(b);
                            break;
                    }   //switch
                }   //for
    
                if (current_container != null)
                    base.Controls.Add(current_container);
    
                current_container = null;
            }
        }
    }
    namespace ui
    {
        public partial class Default : UIEngine
        {
            public Default() : base(0) { }
    
            protected void Page_Load(object sender, EventArgs e)
            {
                base.BuildUI();
            }
        }
    }
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ui.Default" %>
    
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>
  2. #2
    Hi,

    I think you should use AbsoluteLayout.
    https://examples1.ext.net/#/Layout/A...e_Layout_Form/

Similar Threads

  1. Replies: 0
    Last Post: Feb 06, 2012, 1:59 PM
  2. Replies: 2
    Last Post: Oct 13, 2011, 5:02 PM
  3. Replies: 6
    Last Post: Sep 20, 2010, 2:48 PM
  4. Gmap control in codebehind
    By edudiana in forum 1.x Help
    Replies: 0
    Last Post: Apr 13, 2010, 7:56 PM
  5. change status of a control from codebehind
    By supermanwah in forum 1.x Help
    Replies: 4
    Last Post: May 13, 2009, 11:18 AM

Posting Permissions