请问我自已新建的控件如何取得style属性?(100分)
weilt 2004-04-30 10:41:44 我自已建的一个控件,加入了table固定格式,有DropDownList,ListBox,和Button和连接数据库等等,我现在就是不知道如何把我新建的控件加入一些如style属性,以及设置bgColor等属性的设置等等。
请问哪位可以帮帮我呀!
以下是代码:
public class Compontision:Control, INamingContainer
{
private DropDownList DDLCOMP = new DropDownList();
private DropDownList DDLDept = new DropDownList();
private DropDownList DDLSECTION = new DropDownList();
private ListBox SelectUnit = new ListBox();
private ListBox SelectedUnit = new ListBox();
public string Value
{
get{return SelectUnit.SelectedValue;}
}
public override string ID
{
get
{
return base.ID;
}
set
{
base.ID = value;
}
}
public override Page Page
{
get
{
return base.Page;
}
set
{
base.Page = value;
}
}
public override bool Visible
{
get
{
return base.Visible;
}
set
{
base.Visible = value;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
}
public override Control FindControl(string id)
{
return base.FindControl (id);
}
public override ControlCollection Controls
{
get
{
return base.Controls;
}
}
protected override void CreateChildControls()
{
this.Controls.Add(new LiteralControl("<table cellSpacing='0' cellPadding='0' border='0' style='LEFT: 100px; POSITION: absolute; TOP: 100px'>"));
this.Controls.Add(new LiteralControl("<tr>"));
this.Controls.Add(new LiteralControl("<td style='HEIGHT: 19px'>"));
DDLCOMP.AutoPostBack = true;
DDLCOMP.SelectedIndexChanged += new EventHandler(this.DDLCOMPSelectedChanged);
DDLCOMP.Width =136;
DDLCOMP.Height =24;
this.Controls.Add(DDLCOMP);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td style='HEIGHT:19px' colspan=3>"));
DDLDept.AutoPostBack =true;
DDLDept.SelectedIndexChanged += new EventHandler(this.DDLDept_SelectedIndexChanged);
DDLDept.Width =136;
DDLDept.Height =24;
this.Controls.Add(DDLDept);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td style='HEIGHT:19px'>"));
DDLSECTION.AutoPostBack = true;
DDLSECTION.SelectedIndexChanged += new EventHandler(this.DDLSECTION_SelectedIndexChanged);
DDLSECTION.Width =136;
DDLSECTION.Height =24;
this.Controls.Add(DDLSECTION);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("</tr>"));
this.Controls.Add(new LiteralControl("<tr>"));
this.Controls.Add(new LiteralControl("<td colSpan='2' rowSpan='4'>"));
SelectUnit.Width =160;
SelectUnit.Height =120;
this.Controls.Add(SelectUnit);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"+" "+"</td>"));
this.Controls.Add(new LiteralControl("<td colSpan='2' rowSpan='4'>"));
SelectedUnit.Width =160;
SelectedUnit.Height =120;
this.Controls.Add(SelectedUnit);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<tr>"));
this.Controls.Add(new LiteralControl("<td align='center'>"));
Button Button1 = new Button();
Button1.Text = ">>>";
Button1.Width=72;
Button1.Height=24;
Button1.Click += new EventHandler(this.Button1_Click);
this.Controls.Add(Button1);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("</tr>"));
this.Controls.Add(new LiteralControl("<tr>"));
this.Controls.Add(new LiteralControl("<td align='center'>"));
Button Button2 = new Button();
Button2.Text ="<<<";
Button2.Width=72;
Button2.Height =24;
Button2.Click += new EventHandler(this.Button2_Click);
this.Controls.Add(Button2);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("</tr>"));
this.Controls.Add(new LiteralControl("<tr>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("</tr>"));
this.Controls.Add(new LiteralControl("<tr>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
Button Button3 = new Button();
Button3.Width =64;
Button3.Height=24;
Button3.Text = "确定";
this.Controls.Add(Button3);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
Button Button4 = new Button();
Button4.Width =64;
Button4.Height=24;
Button4.Text ="取消";
this.Controls.Add(Button4);
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("<td>"));
this.Controls.Add(new LiteralControl("</td>"));
this.Controls.Add(new LiteralControl("</tr>"));
this.Controls.Add(new LiteralControl("</table>"));
}