I am trying the take the following code and change it to VB. Can someone tell me what the equivelent to this., is for VB?
public class DynamicallyAddingControls : System.Web.UI.Page
{
// a Property that manages a counter stored in ViewState
protected int NumberOfControls
{
get{return (int)ViewState["NumControls"];}
set{ViewState["NumControls"] = value;}
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
//Initiate the counter of dynamically added controls
this.NumberOfControls = 0;
else
//Controls must be repeatedly be created on postback
this.createControls();
}
// This routine creates the controls and assigns a generic ID
private void createControls()
{
int count = this.NumberOfControls;
for(int i = 0; i < count; i++)
{
TextBox tx = new TextBox();
tx.ID = "ControlID_" + i.ToString();
//Add the Controls to the container of your choice
Page.Controls.Add(tx);
}
}
// example of dynamic addition of controls
// note the use of the ViewState variable
private void addSomeControl()
{
TextBox tx = new TextBox();
tx.ID = "ControlID_" + NumberOfControls.ToString();
Page.Controls.Add(tx);
this.NumberOfControls++;
}
}
public class DynamicallyAddingControls : System.Web.UI.Page
{
// a Property that manages a counter stored in ViewState
protected int NumberOfControls
{
get{return (int)ViewState["NumControls"];}
set{ViewState["NumControls"] = value;}
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
//Initiate the counter of dynamically added controls
this.NumberOfControls = 0;
else
//Controls must be repeatedly be created on postback
this.createControls();
}
// This routine creates the controls and assigns a generic ID
private void createControls()
{
int count = this.NumberOfControls;
for(int i = 0; i < count; i++)
{
TextBox tx = new TextBox();
tx.ID = "ControlID_" + i.ToString();
//Add the Controls to the container of your choice
Page.Controls.Add(tx);
}
}
// example of dynamic addition of controls
// note the use of the ViewState variable
private void addSomeControl()
{
TextBox tx = new TextBox();
tx.ID = "ControlID_" + NumberOfControls.ToString();
Page.Controls.Add(tx);
this.NumberOfControls++;
}
}