In order to demonstrate that it is also possible to reuse the code behind along with the user control we will add some custom code to the page_load event.
public string Company { get { return _company; } set { _company = value; } }
public string Year { get { return _year; } set { _year = value; } }
protected void Page_Load(object sender, System.EventArgs e) { Response.Write("DateBox Page Load Event successfully called!"); lblDate.Text = Year; lblCompany.Text = Company; }
private string _company, _year; |
Note : It is also possible to use the ascx files as a single file and write directly the custom code in it.