// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Drawing; using System.Windows.Forms; using System.IO; using System.Net; namespace E { public class MainForm : Form { private Button button1; private ListBox listBox1; public MainForm() { InitializeComponent(); } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } private void InitializeComponent() { int maxval = 3; listBox1 = new ListBox(); button1 = new Button(); SuspendLayout(); listBox1.Location = new Point(50, 50); listBox1.Size = new Size(100, 100); HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost/select.asp"); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; StreamWriter post = new StreamWriter(req.GetRequestStream()); post.Write("max=" + maxval); post.Close(); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); StreamReader sr = new StreamReader(resp.GetResponseStream()); string line; while((line = sr.ReadLine()) != null) { string[] parts = line.Split(" ".ToCharArray()); listBox1.Items.Add(parts[1]); } sr.Close(); resp.Close(); button1.Location = new Point(50, 200); button1.Size = new Size(100, 20); button1.Text = "OK"; button1.Click += new EventHandler(Button1Click); ClientSize = new Size(200, 300); Controls.Add(button1); Controls.Add(listBox1); Text = "Demo"; ResumeLayout(false); } private void Button1Click(object sender, System.EventArgs e) { MessageBox.Show(listBox1.SelectedItem.ToString()); } } }