protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { // Display results view MultiView1.SetActiveView(View2); NoBotState state; Label1.Text = string.Format( (NoBot1.IsValid(out state) ? "Congratulations, \"{1} {2}\", you do not appear to be a bot. (Details: {0})" : "Rejected; user appears to be a bot. (Details: {0})"), state.ToString(), TextBox1.Text, TextBox2.Text); StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <DateTime, string> kvp in NoBot.GetCopyOfUserAddressCache()) { sb.AppendFormat("{0}: {1}<br />", kvp.Key.ToString("u"), kvp.Value); } Label2.Text = sb.ToString(); } else { // Display input view MultiView1.SetActiveView(View1); } }
protected void NoBot1_GenerateChallengeAndResponse(object sender, AjaxControlToolkit.NoBotEventArgs e) { NoBotState state; NoBot1.IsValid(out state); Label1.Text = state.ToString(); }
protected void Page_Load(object sender, EventArgs e) { // Prevent IE from caching the page during test runs (which breaks the tests) Response.Cache.SetCacheability(HttpCacheability.NoCache); // Capture the reported NoBot states NoBotState state1; NoBotState state2; if ((NoBot1.IsValid() != NoBot1.IsValid(out state1)) || (NoBot2.IsValid() != NoBot2.IsValid(out state2))) { throw new Exception("Results of IsValid methods differ."); } Label1.Text = state1.ToString(); Label2.Text = state2.ToString(); }
protected void btnSend_Click(object sender, EventArgs e) { if (Page.IsValid && NoBot1.IsValid()) { MailAddress ma = new MailAddress(txtEmail.Text, txtName.Text); string szBody = txtComments.Text + "\r\n\r\nUser = "******"anonymous") + "\r\nSent: " + DateTime.Now.ToLongDateString(); string szSubject = String.Format(CultureInfo.CurrentCulture, "{0} - {1}", Branding.CurrentBrand.AppName, txtSubject.Text); using (MailMessage msg = new MailMessage() { From = new MailAddress(Branding.CurrentBrand.EmailAddress, String.Format(CultureInfo.InvariantCulture, Resources.SignOff.EmailSenderAddress, Branding.CurrentBrand.AppName, txtName.Text)), Subject = szSubject, Body = szBody }) { if (fuFile.HasFiles) { foreach (HttpPostedFile pf in fuFile.PostedFiles) { msg.Attachments.Add(new Attachment(pf.InputStream, pf.FileName, pf.ContentType)); } } msg.ReplyToList.Add(ma); util.AddAdminsToMessage(msg, true, ProfileRoles.maskCanContact); util.SendMessage(msg); } mvContact.SetActiveView(vwThanks); string szOOF = ConfigurationManager.AppSettings["UseOOF"]; if (!String.IsNullOrEmpty(szOOF) && String.Compare(szOOF, "yes", StringComparison.Ordinal) == 0) { util.NotifyUser(szSubject, Branding.ReBrand(Resources.EmailTemplates.ContactMeResponse), ma, false, false); } // if this was done via iPhone/iPad (i.e., popped up browser), suppress the "return" link. if (util.GetIntParam(Request, "noCap", 0) != 0) { lnkReturn.Visible = false; } } }
protected void btnSend_Click(object sender, EventArgs e) { NoBotState state; // if condition to check the response state of NoBot if (NoBot1.IsValid(out state)) { Label2.Text = state.ToString(); } else { Label2.Text = state.ToString(); } StringBuilder sb = new StringBuilder(); // foreach loop to get cached IP address and datetime assocated with it(when last postback was occurred) foreach (System.Collections.Generic.KeyValuePair <DateTime, string> keyValue in NoBot.GetCopyOfUserAddressCache()) { sb.AppendFormat("{0}: {1}<br />", keyValue.Key.ToString(), keyValue.Value); } Label4.Text = sb.ToString(); }
protected void Button1_Click(object sender, EventArgs e) { if (NoBot1.IsValid(out durun)) { Response.Write(""); } else { Response.Write("<script>alert('按鈕速度太快,是不是機器人?')</script>"); } if (TextBox1.Text.Length == 0) { Label2.Text = "不可為空"; return; } else { Label2.Text = "輸入成功 "; lblString.Text += "\r\n" + "*" + TextBox1.Text + "<br>"; } }