Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help With C# Program  (Read 3145 times)

0 Members and 1 Guest are viewing this topic.

rjoy612

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    Help With C# Program
    « on: February 19, 2012, 11:53:20 PM »
    I need help with my program. Here is the source code. It is in C#. My problem is that it is submitting after I click the submit button but it continues to submit. I want it to submit once and then stop. I don't want it to close. Just kind of pause/ be finished. Please help me out. Thanks!

    Code: [Select]
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsFormsApplication1
    {
        public partial class frmMain : Form
        {
            public frmMain()
            {
                InitializeComponent();
            }

            private void webWeebly_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                webWeebly.DocumentText.Contains("Comment");

                webWeebly.Document.GetElementById("input-705652889195239588").SetAttribute("value", txtFirst.Text);
                webWeebly.Document.GetElementById("input-705652889195239588-1").SetAttribute("value", txtLast.Text);
                webWeebly.Document.GetElementById("input-959379682711960375").SetAttribute("value", txtEmail.Text);
                webWeebly.Document.GetElementById("input-574159613867142544").SetAttribute("value", txtComment.Text);

                HtmlElementCollection WebElements = webWeebly.Document.All;
                foreach (HtmlElement SubBtn in WebElements)
                {
                    if (SubBtn.GetAttribute("value") == "Submit")
                    {
                        SubBtn.InvokeMember("click");
                       

                    }
                }

            }

            private void btnSubmit_Click(object sender, EventArgs e)
            {

                webWeebly.Navigate("http://firecactus.weebly.com/contact-us.html");
                while (!(webWeebly.ReadyState == WebBrowserReadyState.Complete))
                {
                    Application.DoEvents();
                   
                }
               
            }
        }
    }

    TheWaffle



      Hopeful
    • Thanked: 4
      • Yes
    • Computer: Specs
    • Experience: Beginner
    • OS: Linux variant
    Re: Help With C# Program
    « Reply #1 on: May 10, 2012, 03:35:51 PM »
    In the submit button event handler you could put something like
    Button Name.visibility = False;
    (It would help if you posted the other file of code (partial class)