Пример #1
0
        //Possibility to query (documentation): http://www.random.org/clients/http/
        private void button1_Click(object sender, EventArgs e)
        {
            var panel   = this.Notify("Please wait...", -1, 0.3, Color.Green, Color.Black, Color.White);
            var options = new AjaxRequestOptions
            {
                //You can also delete the Data object and add this to the URL:
                //?min=1&max=52&col=1&format=plain&rnd=new
                //It will behave identical, butshow that both options (Data and URL) are possible.
                Data = new {
                    min    = 1,
                    max    = 52,
                    col    = 1,
                    format = "plain",
                    rnd    = "new"
                },
                Url      = textBox2.Text,
                Type     = (AjaxRequestType)Enum.Parse(typeof(AjaxRequestType), comboBox1.SelectedItem.ToString()),
                Complete = (s, ev) =>
                {
                    Controls.Remove(panel);
                    panel.Dispose();
                },
                Success = (s, ev) =>
                {
                    textBox1.Text = ev.ResponseText.Replace("\n", "\r\n");
                    textBox3.Text = MakeHeaders(s);
                }
            };

            options.AddStatusCodeHandler(System.Net.HttpStatusCode.OK, (s, ev) =>
            {
                MessageBox.Show("I received something with StatusCode 200!");
            });
            AjaxRequest.Create(options);
        }