protected void Page_Load(object sender, System.EventArgs e) { this.model = this.Session["model"] as TasksModel; validationLabel.Visible = false; if (!this.IsPostBack) { //This is executed first time the page is loaded. ViewState["referrer"] = Request.UrlReferrer; //Save id of the task we are editing in the view state. It will be null for new task. ViewState["taskId"] = Request.QueryString["taskId"]; Task task = GetTask(); if (task == null) { //Creating a new task. formLabel.Text = "New Custom Task"; taskNameEdit.Text = "New Task"; iCalendarText.Text = "DTSTART:20040101\r\nRRULE:FREQ=DAILY;COUNT=10"; } else { //Editing existing task. formLabel.Text = "Edit Custom Task"; taskNameEdit.Text = task.Name; iCalendarText.Text = task.Pattern.ToiCalendar(); } this.examplesText.Text = "Daily for 10 occurrences:\r\n" + "DTSTART:20040902\r\n" + "RRULE:FREQ=DAILY;COUNT=10\r\n" + "\r\n" + "Weekly on Tuesday and Thursday for 5 weeks:\r\n" + "DTSTART;TZID=US-Eastern:20040902T090000\r\n" + "RRULE:FREQ=WEEKLY;UNTIL=20041007T000000Z;WKST=SU;BYDAY=TU,TH\r\n" + "\r\n" + "Monthly on the 1st Friday for ten occurrences:\r\n" + "DTSTART:20040903T090000\r\n" + "RRULE:FREQ=MONTHLY;COUNT=10;BYDAY=1FR\r\n" + "\r\n" + "Monthly on the first and last day of the month for 10 occurrences:\r\n" + "DTSTART:20040930T090000\r\n" + "RRULE:FREQ=MONTHLY;COUNT=10;BYMONTHDAY=1,-1\r\n"; } }
protected void Page_Load(object sender, EventArgs e) { if (this.Session["model"] == null) { //Create new model and cache it in the session state. this.model = new TasksModel(); this.model.CreateSampleTasks(); this.Session["model"] = this.model; } else { //Restore model from the cache this.model = this.Session["model"] as TasksModel; } if (!this.IsPostBack) { BindGrids(); } }
/// <summary> /// Called when the page is loaded. When the page is loaded first time fills the controls with either /// defaults for new task or with information from the existing task. /// </summary> protected void Page_Load(object sender, System.EventArgs e) { this.model = this.Session["model"] as TasksModel; validationLabel.Visible = false; if (!this.IsPostBack) { //This is executed first time the page is loaded. ViewState["referrer"] = Request.UrlReferrer; //Fill combo boxes with standard choices. WebUtil.SetDataSource(monthlyDayCombo, EditTaskController.CreateDayList()); WebUtil.SetDataSource(monthlyDayOfWeekCombo, EditTaskController.CreateDayOfWeekList()); WebUtil.SetDataSource(monthlyNthOccurrenceCombo, EditTaskController.CreateNthOccurrenceList()); WebUtil.SetDataSource(monthlyDayOccurrenceCombo, EditTaskController.CreateWeekDayOccurrenceList()); WebUtil.SetDataSource(monthlyWeekDayTypeCombo, EditTaskController.CreateWeekDayTypeList()); WebUtil.SetDataSource(yearlyDayCombo, EditTaskController.CreateDayList()); WebUtil.SetDataSource(yearlyDayOfWeekCombo, EditTaskController.CreateDayOfWeekList()); WebUtil.SetDataSource(yearlyDayMonthCombo, EditTaskController.CreateMonthList()); WebUtil.SetDataSource(yearlyDayOfWeekMonthCombo, EditTaskController.CreateMonthList()); WebUtil.SetDataSource(yearlyNthOccurrenceCombo, EditTaskController.CreateNthOccurrenceList()); WebUtil.SetDataSource(yearlyDayOccurrenceCombo, EditTaskController.CreateWeekDayOccurrenceList()); WebUtil.SetDataSource(yearlyWeekDayTypeCombo, EditTaskController.CreateWeekDayTypeList()); WebUtil.SetDataSource(yearlyWeekDayMonthCombo, EditTaskController.CreateMonthList()); //Save id of the task we are editing in the view state. It will be null for new task. ViewState["taskId"] = Request.QueryString["taskId"]; EditTaskController controller = new EditTaskController(); if (GetTask() == null) { //Creating a new task. formLabel.Text = "New Task"; SetTaskData(controller.NewTask()); } else { //Editing existing task. formLabel.Text = "Edit Task"; SetTaskData(controller.LoadTask(GetTask())); } } }