**** c#***,
skyddade utan laga kraft Page_Load (anmärka avsändaren, EventArgs e),
{
om (! IsPostBack)
CreateCtrls ();
}
privata utan laga kraft CreateCtrls ()
{
DropDownList ddl1 = nya DropDownList ();
ddl1.ID = ”ddl1”;
ddl1.Items.Add (”asdf0”);
ddl1.Items.Add (”asdf1”);
ddl1.Items.Add (”asdf2”);
ddl1.Items.Add (”asdf3”);
pnl. Controls.Add (ddl1);
DropDownList ddl2 = nya DropDownList ();
ddl2.ID = ”ddl2”;
ddl2.Items.Add (”lkjh0”);
ddl2.Items.Add (”lkjh1”);
ddl2.Items.Add (”lkjh2”);
ddl2.Items.Add (”lkjh3”);
pnl. Controls.Add (ddl2);
ViewState [”ControlsAdded2”] = true;
}
skyddad utan laga kraft btn1_Click (anmärka avsändaren, EventArgs e),
{
}
skyddad åsidosättande utan laga kraft LoadViewState (anmärka savedState),
{
base.LoadViewState (savedState);
om (ogiltig ViewState [”controlsadded1”] ==)
{
CreateCtrls ();
}
}
**** aspx***,
|