protected void btnSubmit_Click(object sender, EventArgs e) { Page.Validate("Poll"); if (Page.IsValid) { int selectedItem = int.Parse(lcAlternatives.SelectedValue); CurrentItem.AddAnswer(Engine.Persister, selectedItem); Response.Cookies.Add(CurrentItem.GetAnsweredCookie(selectedItem)); Response.Redirect(CurrentPage.Url); } }
public ActionResult Submit(int?selectedItem) { if (selectedItem == null) { ModelState.AddModelError("Poll.Errors", Resources.Poll.MakeSelection); } else { var cookie = Request.Cookies[CurrentItem.GetAnsweredCookie(selectedItem.Value).Name]; if (cookie != null && cookie.Value != null) { ModelState.AddModelError("Poll.Errors", Resources.Poll.AlreadyVoted); } } if (ModelState.IsValid) { CurrentItem.AddAnswer(Engine.Persister, selectedItem.Value); Response.Cookies.Add(CurrentItem.GetAnsweredCookie(selectedItem.Value)); } return(ViewParentPage()); }