I have been attempting to write an auto-login code for some websites that I frequent, but one of the website's forms has an odd submit button. Instead of being the usual button that you can call by it's Id it's instead a link.

I was actually wondering if I could call this in the same way I have been filling out the information in the other forms?

Here's the "buttons" code

<a class="blue-button" href="javascript:void(0)" onclick="Form.submit(this)">

and here's my code for filling out the form.

private void button1_Click(object sender, EventArgs e)
        {
            browser.Navigate(@"https://us.battle.net/login/login.xml?ref=https%3A%2F%2Fwww.worldofwarcraft.com%2Faccount%2F&app=wam");
        }

        private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            browser.Document.GetElementById("accountName").SetAttribute("value", accountName);
            browser.Document.GetElementById("password").SetAttribute("value", accountPass);
           // browser.Document.GetElementsBy... Here's where I'm getting off.

I've also tried sending the {ENTER} key to the website, and this didn't work. maybe I did it wrong though

Thanks in advance for any help

Hi there,

I am also new to this kind of programming. Meaning trying to built a C# winforms application which will allow me to login to a site and fetch relevant data or post some queries/datas.

I Came to this section to post my question but found your answer. I did some investigation via google and have a solution as to how to login to the site you mentioned. I created an account there and now am able to login using the winforms application.

here is what you need

webBrowser1.Document.GetElementsByTagName("a")[11].InvokeMember("click");

it would work just fine!!
Basically the 12th tag is where the form submitt takes place, and InvokeMember method raised the onclick even for the button!! :) Happy days!! I will post my own question as a separate thread. Thanks to you I learnt a new stuff!!

' this is vb try to convert it to c# and it will work for you.
'append this code just below after filling your form. it will search for 'the login link and click it


Dim loginLink As HtmlElementCollection
loginLink = WebBrowser1.Document.Links

For i As Integer = 0 To loginLink.Count - 1

If loginLink.Item(i).InnerText = "Login" Then

loginLink.Item(i).InvokeMember("click")

End If
Next

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.