home links tips
code users tools tutorials projects web help design
mudabone
suletzki trans48
nutrition reality
MarthaAttire!
| |
tips Dynamic Controls And View State
|
Add Web Control Dynamically
Write a function like:
private void addTextBox() { System.Web.UI.WebControls.TextBox tb = new TextBox(); tb.ID = "tbControl"; tb.Text = "Hello"; Page.Controls[1].Controls.Add(tb); }
Call it from OnInit:
override protected void OnInit(EventArgs e) { InitializeComponent(); addTextBox(); base.OnInit(e); }
Retrieve control to work with it
private void Page_Load(object sender, System.EventArgs e) { if (IsPostBack) { TextBox tb = (TextBox)Page.FindControl("tbControl"); tb.Text = tb.Text.ToUpper(); } }
Last Modified 12/13/04 9:19 AM
| Hide Tools
|