.NET 2.0 Web Controls

L

Lewis Harvey

This may be one of those simple questions, but I can't seem to find the
answer.

I want to create a control, called AdminForm, for example, then this will
render a table header and footer. Then I was the developer to be able to
drop other controls into this. But so they render between the header and
footer of the table. Then the controls have <tr> in them and everything will
be lined up correctly. My code is a follows, can someone point me in the
right direction?


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Text;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace IX4Controls

{

[DefaultProperty("Text")]

[ToolboxData("<{0}:IX4FormControl
runat=server></{0}:IX4FormControl>")]

public class IX4FormControl : WebControl

{

[Bindable(true), Category("Appearance"), DefaultValue(""),
Description("Header for the Form"), Localizable(true)]

public virtual String FormHeader

{

get

{

string s = (string)ViewState["FormHeader"];

return (s == null) ? "" : s;

}

set

{

ViewState["FormHeader"] = value;

}

}

protected override void CreateChildControls()

{

//Start the table

Literal startTableRow = new Literal();

startTableRow.Text = "<table><tr><td align=\"center\"
colspan=\"2\">";

this.Controls.Add(startTableRow);

//Label for form header

Label lab1 = new Label();

lab1.Text = FormHeader;

lab1.ForeColor = this.ForeColor;

this.Controls.Add(lab1);

//End of header

Literal endTableLit = new Literal();

endTableLit.Text = "</td></tr>";

this.Controls.Add(endTableLit);




I WANT USER CONTROLS TO BE ADDED HERE USING THE DESIGN VIEW.


//Aend of table

Literal endTableLit = new Literal();

endTableLit.Text = "</table>";

this.Controls.Add(endTableLit);

//call the parent method

base.CreateChildControls();

}

}

}

Any Ideas?

Regards,



Lewis Harvey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top