protected void Page_Load(object sender, EventArgs e) { if (Session["user"] != null) { string userid = Session["user"].ToString(); AccountP acc = new AccountP(userid); //get all info string fullname = acc.getUserFullname(); //check if fetched data has errors if (acc.serverResponse == "500") { Response.Redirect("~/error"); } else { idname.Text = fullname; //get days int i = 1; while (i < 32) { ddList.Items.Add(new ListItem(i.ToString(), i.ToString())); i++; } //get months int j = 1; while (j < 13) { Dt dt = new Dt(); string monthName = dt.getMonthByVal(j); mmList.Items.Add(new ListItem(monthName, j.ToString())); j++; } //get years int k = 0; int year = 2018; yyList.Items.Add(new ListItem(year.ToString(), year.ToString())); while (k < 10) { year = year + 1; yyList.Items.Add(new ListItem(year.ToString(), year.ToString())); k++; } //get hours int m = 1; while (m < 13) { if (m < 10) { hList.Items.Add(new ListItem("0" + m.ToString(), "0" + m.ToString())); } else { hList.Items.Add(new ListItem(m.ToString(), m.ToString())); } m++; } //get minutes int n = 0; while (n < 60) { if (n < 10) { mList.Items.Add(new ListItem("0" + n.ToString(), "0" + n.ToString())); } else { mList.Items.Add(new ListItem(n.ToString(), n.ToString())); } n++; } //am pm tList.Items.Add(new ListItem("am", "AM")); tList.Items.Add(new ListItem("pm", "PM")); //priority list pList.Items.Add(new ListItem("High", "1")); pList.Items.Add(new ListItem("Medium", "2")); pList.Items.Add(new ListItem("Low", "3")); //repeat list rList.Items.Add(new ListItem("No repeat", "1")); rList.Items.Add(new ListItem("Daily", "2")); rList.Items.Add(new ListItem("Weekly", "3")); rList.Items.Add(new ListItem("Monthly", "4")); rList.Items.Add(new ListItem("Yearly", "5")); //set defaults Dt dt2 = new Dt(); if (!IsPostBack) { schTitle.Text = "My event"; ddList.SelectedValue = dt2.getDayVal().ToString(); mmList.SelectedValue = dt2.getMonthVal().ToString(); yyList.SelectedValue = dt2.getYearVal().ToString(); hList.SelectedValue = dt2.getHourVal().ToString(); mList.SelectedValue = dt2.getMinuteVal().ToString(); } } } else { Response.Redirect("~/login"); } }