Apr 05, 2012, 4:21 PM
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
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>