示例#1
0
 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);
     }
 }
示例#2
0
        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());
        }