|
The following is a sample code I made for reference only:
public class WebForm2: System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.ListBox ListBox1;
protected System.Web.UI.WebControls.Button Button1;
Ransom
private void Page_Load (object sender, System.EventArgs e)
{
// Place user code here to initialize the page
}
#region Web Form Designer Generated Code
override protected void OnInit (EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Forms Designer.
//
InitializeComponent ();
base.OnInit (e);
}
Ranch
/// <summary>
/// Designer supports required methods-don't modify with code editor
/// The contents of this method.
/// </ summary>
private void InitializeComponent ()
{
this.Button1.Click + = new System.EventHandler (this.Button1_Click);
this.Load + = new System.EventHandler (this.Page_Load);
}
#endregion
private void Button1_Click (object sender, System.EventArgs e)
{
this.ListBox1.Items.Add (this.TextBox1.Text);
}
} |
|