Esempio n. 1
0
        private void buttonGo_Click(object sender, EventArgs e)
        {
            // user clicked the Go! button

            try
            {
                // grab the address from the address bar
                var address = textboxAddress.Text;

                if (string.IsNullOrWhiteSpace(address))
                {
                    throw new Exception("Address cannot be empty");
                }

                // fetch the content
                var content = fetcher.Fetch(address);

                if (content == null)
                {
                    throw new Exception("Received null content");
                }

                // put the content in the content box
                textboxContent.Text = content;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }
Esempio n. 2
0
        private void buttonGo_Click(object sender, EventArgs e)
        {
            // user clicked the Go! button
            try
            {
                // grab the address from the address bar
                string address = textboxAddress.Text;

                // fetch the content
                string content = fetcher.Fetch(address);

                // put the content in the content box
                textboxContent.Text = content;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }