protected void Page_Load(object sender, EventArgs e) { //TODO: Test !IsPostBack - unsuccessful if (!IsPostBack) { cont = "document.getElementById('" + contestsDDL.ClientID + "').options[0].value"; //contestID == 0 && problemID == 0 prob = "0"; if (contestID != 0) { cont = String.Format("{0}:{1}", contestID, Contest.GetContest(contestID).Time); prob = problemID.ToString(); } ContestTime type = ContestTime.None; if (current) { type |= ContestTime.Current; } if (past) { type |= ContestTime.Past; } if (forthcoming) { type |= ContestTime.Forthcoming; } foreach (Contest c in Contest.GetContests(type)) { contestsDDL.Items.Add(new ListItem(c.Name, String.Format("{0}:{1}", c.ID, c.Time))); } if (contestID != 0) { contestsDDL.SelectedValue = cont; } } if (contestsDDL.Items.Count != 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "selc", "function SelectedContestChanged(arg, context){" + Page.ClientScript.GetCallbackEventReference(this, "arg", "ProcessCallbackResult", "context", true) + ";" + fcalling + ";}", true); string script = "SelectedContestChanged("; if (contestID != 0) { script += "\"" + cont + "\",'ddl');"; } else { script += cont + ",'ddl');"; } Page.ClientScript.RegisterStartupScript(GetType(), "initproblemsDDL", script, true); contestsDDL.Attributes.Add("onchange", "javascript:SelectedContestChanged(this.options[this.selectedIndex].value,'ddl');"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "check", "CheckContestLack()", true); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ContestTime type = ContestTime.None; if (current) { type |= ContestTime.Current; } if (past) { type |= ContestTime.Past; } if (forthcoming) { type |= ContestTime.Forthcoming; } contestsDDL.DataSource = Contest.GetContests(type); contestsDDL.DataBind(); if (contestsDDL.Items.Count == 0) { errmessTR.Visible = true; ddlTR.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Name"); dt.Columns.Add("Monitor"); dt.Columns.Add("Beginning", typeof(DateTime)); dt.Columns.Add("Ending", typeof(DateTime)); dt.Columns.Add("Status"); Contest[] cons = Contest.GetContests(ContestTime.Current | ContestTime.Forthcoming | ContestTime.Past); foreach (Contest cnt in cons) { DataRow dr = dt.NewRow(); dr[0] = cnt.ID; if (cnt.Time == ContestTime.Forthcoming && !Page.User.IsInRole("Administrator")) { dr[1] = cnt.Name; } else { dr[1] = UrlRenderer.RenderContestUrl(cnt); } if (cnt.Time == ContestTime.Forthcoming && !Page.User.IsInRole("Judge")) { dr[2] = "Недоступен"; } else { dr[2] = UrlRenderer.RenderMonitorUrl(cnt); } dr[3] = cnt.Beginning; dr[4] = cnt.Ending; switch (cnt.Time) { case ContestTime.Current: dr[5] = String.Format("Идет (конец через {0})", TimeUtils.BeautifyTimeSpan(cnt.Ending - DateTime.Now, false)); break; case ContestTime.Forthcoming: dr[5] = String.Format("Еще не начиналось (начало через {0})", TimeUtils.BeautifyTimeSpan(cnt.Beginning - DateTime.Now, false)); break; case ContestTime.Past: dr[5] = "Закончилось"; break; } dt.Rows.Add(dr); } contestsGV.DataSource = dt; contestsGV.DataBind(); }