J
J.Marsch
I have created a composite control that combines a Label and a Textbox,
where the label appears immediately above the textbox. This seems to work
fine at runtime, but at design time, when you drop the control onto a web
form, the control appears as a tiny, empty box on the webform. I would like
for it to render as it will look at run time (or at least close). How would
I do that?
Here's the code ( am using AddChildControls, not Render)
public class EditBoxLabelControl : System.Web.UI.WebControls.WebControl,
System.Web.UI.INamingContainer
{
protected System.Web.UI.WebControls.TextBox EditBox;
protected System.Web.UI.WebControls.Label FieldLabel;
protected override void CreateChildControls()
{
this.FieldLabel = new System.Web.UI.WebControls.Label();
this.FieldLabel.Text = "Label";
this.Controls.Add(this.FieldLabel);
System.Web.UI.WebControls.Literal literal = new
System.Web.UI.WebControls.Literal();
literal.Text = "<br>";
this.Controls.Add(literal);
this.EditBox = new System.Web.UI.WebControls.TextBox();
this.EditBox.Text = "test";
this.Controls.Add(this.EditBox);
}
}
where the label appears immediately above the textbox. This seems to work
fine at runtime, but at design time, when you drop the control onto a web
form, the control appears as a tiny, empty box on the webform. I would like
for it to render as it will look at run time (or at least close). How would
I do that?
Here's the code ( am using AddChildControls, not Render)
public class EditBoxLabelControl : System.Web.UI.WebControls.WebControl,
System.Web.UI.INamingContainer
{
protected System.Web.UI.WebControls.TextBox EditBox;
protected System.Web.UI.WebControls.Label FieldLabel;
protected override void CreateChildControls()
{
this.FieldLabel = new System.Web.UI.WebControls.Label();
this.FieldLabel.Text = "Label";
this.Controls.Add(this.FieldLabel);
System.Web.UI.WebControls.Literal literal = new
System.Web.UI.WebControls.Literal();
literal.Text = "<br>";
this.Controls.Add(literal);
this.EditBox = new System.Web.UI.WebControls.TextBox();
this.EditBox.Text = "test";
this.Controls.Add(this.EditBox);
}
}