Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,I'm new at visual basic and I try auto login for website

Well,I'm stucked somewhere

I can insert id and pw but cant press login button because there's no div name?

Here's the code

XML
<form name="giris" method="POST" action="/auth/signin">
            <input class="data-input" placeholder="Kullanıcı Adı" name="kullanici_adi">
            <input class="data-input" placeholder="Şifreniz" type="password" name="kullanici_sifre">
            <input type="submit" value="Giriş Yap" class="buton"><br>
                        </form>

My vb code is

VB
WebBrowser1.Document.GetElementById("kullanici_adi").SetAttribute("nick", TextBox1.Text)
 WebBrowser1.Document.GetElementById("kullanici_sifre").SetAttribute("sifre", TextBox2.Text)
 WebBrowser1.Document.GetElementById("submit").InvokeMember("buton")
Posted

You try to set attributes with names like nick and sifre. This variable names doesn't exist. Try to set the value attribute. Also, to simulate a click, don't use this code:
VB.NET
WebBrowser1.Document.GetElementById("submit").InvokeMember("buton")

But use this code:
VB.NET
WebBrowser1.Document.GetElementById("submit").InvokeMember("click")

Hope this helps.
 
Share this answer
 
Don't do the wrong thing and then apologise. If you wanted to apologise, you wouldn't have done it. Your code won't work. You clearly are a beginner, and that is fine, but you're very confused right now. Buy a book and work through it. The web form won't work as 'button' is misspelled. You can use Document.Forms(0).Submit, if the browser object supports it, but learning to use VB to call javascript methods is not a sane way to learn VB, it's really kind of pointless. Write VB programs, not just code against the browser control, which is not really that useful, and is only going to teach you to call existant APIs, not write real code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900