Aggiunta dinamica di Web Control al caricamento.
In ASP.NET è possibile aggiungere dinamicamente dei Web Control alla pagina durante l'evento Page_Load. E' possibile quindi avere una pagina inizialmente vuota e costruirla dinamicamente (recuperando eventualmente le informazioni su un database). Ecco un esempio:
private void Page_Load(object sender, System.EventArgs e)
{
// Aggiungo un tab control
TabStrip1 = new Microsoft.Web.UI.WebControls.TabStrip();
Tab1 = new Microsoft.Web.UI.WebControls.Tab();
Tab2 = new Microsoft.Web.UI.WebControls.Tab();
TabStrip1.Font.Name = "Verdana";
TabStrip1.Font.Bold = false;
TabStrip1.Font.Size = 8;
Tab1.Text = "About Us";
Tab1.ID = "AboutUs";
TabStrip1.Items.Add(Tab1);
Tab2.Text = "Products and Services";
Tab2.ID = "ProductsAndServices";
TabStrip1.Items.Add(Tab2);
this.Controls.Add(TabStrip1);
}
Autore: Fabio Santini [MS]
Data: 19 luglio 2002
Ultimo aggiornamento: 23 luglio 2004
Categorie: