Программирование в IIS

Пример 3.10

/// <summary> /// Summary description for EventClient. /// </summary> public class EventClient : System.Web.UI.Page { protected System.Web.UI.WebControls.Calendar Calendar1; protected System.Web.UI.WebControls.TextBox txtName; protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.Label Label2; protected System.Web.UI.WebControls.TextBox txtDescription; protected System.Web.UI.WebControls.Label lblFeedback; protected System.Web.UI.WebControls.Button btnAdd;

private void Page_Load(object sender, System.EventArgs e) { //don't show the feedback text box until //there is a good reason this.lblFeedback.Visible = false;

//make the numbers red that are selected in calendar this.Calendar1.SelectedDayStyle.ForeColor = System.Drawing.Color.Red; }

#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the // ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }

/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); this.Load += new System.EventHandler(this.Page_Load);

} #endregion

private void btnAdd_Click(object sender, System.EventArgs e) { Events myEvents = new Events(); anEvent myEvent = new anEvent();

//get the name myEvent.Name = this.txtName.Text;

//get the date/time myEvent.DateTime = this.Calendar1. SelectedDate.Date;

//get the description myEvent.Description = this.txtDescription.Text;

myEvents.Event = myEvent;

//add it if (myEvents.Add()) { this.lblFeedback.Visible = true; lblFeedback.Text = "Wrote a new date with ID = " + myEvent.ID;

} else { this.lblFeedback.Visible = true; lblFeedback.Text = "Unable to write date"; } } }

Листинг 3.10. Source Code for Events Add Function Test Harness - Web Form EventClient.aspx

Закрыть окно

Содержание  Назад  Вперед