Need Help!
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Hello Friends, | ASSLAM-O-ALAIKUM
Dear brothers/sisters, as i have discussed that I'm new in vb and that's why i need help. Some days ago i was watching a video on youtube about how to make a website login. In that video he uses yahoo login page. and i think i will also create for a website. and i start working on that. That tutorial was good and something like this :-
He add 2 Textboxes for username and password
Two Labels
A Web browser
2 Buttons ( LOGIN | NAVIGATE ) [ Well he make navigate button so that the person who is using that program should click on Navigate button to Open the site, But i didn't use it and use this in Form webbrowser1.navigate (" http://www.site.com " )
Well It was easy after watching his tutorial but one thing in which I was stucked is that he go to yahoo's Login Page and View it's source and find a code so that he can use it so that you don't need to click on the login button after typing username and password it will automatically log in when you will press login button on your program!
He do this
but when i try to found for a site which was a forum actually a phbb forum and i found one too it was not .save it was login
and i use that in it but it do not work i try some other that were present in the site's source like sid etc but that were also not working.
That was my site's Code
I use redirect - login - sid
but it didn't work with any of them
For Better understanding what I'm actually trying to ask you can see that same video!
http://www.youtube.com/watch?v=9EJXzWasTq4
Please Help me what should i use now instead of that code so my program also works like that one!
Dear brothers/sisters, as i have discussed that I'm new in vb and that's why i need help. Some days ago i was watching a video on youtube about how to make a website login. In that video he uses yahoo login page. and i think i will also create for a website. and i start working on that. That tutorial was good and something like this :-
He add 2 Textboxes for username and password
Two Labels
A Web browser
2 Buttons ( LOGIN | NAVIGATE ) [ Well he make navigate button so that the person who is using that program should click on Navigate button to Open the site, But i didn't use it and use this in Form webbrowser1.navigate (" http://www.site.com " )
Well It was easy after watching his tutorial but one thing in which I was stucked is that he go to yahoo's Login Page and View it's source and find a code so that he can use it so that you don't need to click on the login button after typing username and password it will automatically log in when you will press login button on your program!
He do this
Code: Select all
Well the code he found from yahoo login source code is that .save which will automatically log in when the user will click on Log in buttonwebbrowser1.getelementbyid(".save").invokemember ("click")
but when i try to found for a site which was a forum actually a phbb forum and i found one too it was not .save it was login
and i use that in it but it do not work i try some other that were present in the site's source like sid etc but that were also not working.
That was my site's Code
I use redirect - login - sid
but it didn't work with any of them
For Better understanding what I'm actually trying to ask you can see that same video!
http://www.youtube.com/watch?v=9EJXzWasTq4
Please Help me what should i use now instead of that code so my program also works like that one!
Hello,
The reason why your code does not work is because "login" is not the ID of your element, but rather it's name. Whereas IDs are supposed to be unique to each element, more than one element can have the same name.
To get a list of all the elements with a given name, you can use this:
The reason why your code does not work is because "login" is not the ID of your element, but rather it's name. Whereas IDs are supposed to be unique to each element, more than one element can have the same name.
To get a list of all the elements with a given name, you can use this:
Code: Select all
Now, assuming you have only one element with the name "login" on that page, or that the first one to appear is the correct login button, you can use the following code to invoke a click on it:loginButtons = WebBrowser1.GetElementsByName("login")
Code: Select all
Since we're assuming that you want to use the first element of the list (which means the index is 0), this should perform a click on your login button cooll;loginButtons(0).invokemember ("click")
In this case, the author of the page did not set an ID for the login button element. This is totally up to the page's creator and is not required. That's why in this case we need to get the element by name.
Hi Master M1nd
Since theirs no element id here is a method of finding elements by their class, i edited the code for the html page you have shown.
Since theirs no element id here is a method of finding elements by their class, i edited the code for the html page you have shown.
Code: Select all
Hope this helps, Smiley cooll; Dim elements As HtmlElementCollection = WebBrowser1.Document.All
For Each element As HtmlElement In elements
If element.GetAttribute("classname").Contains ("button1") Then
element.InvokeMember("click")
End If
Next
#Smiley
This does essentially the same thing as I posted, but it requires you to change the page source (the page might not be his) and it iterates over ALL of the elements in the page, not just those with the specified name.
This does essentially the same thing as I posted, but it requires you to change the page source (the page might not be his) and it iterates over ALL of the elements in the page, not just those with the specified name.
comathi wrote:#SmileyOops i didnt read every reply, dont i look like a fool LOL idoit;
This does essentially the same thing as I posted, but it requires you to change the page source (the page might not be his) and it iterates over ALL of the elements in the page, not just those with the specified name.
hmm I'm not the creator but the one who manages the forum is my friend. But he also didn't design that template!
Well Now what should i do? Any other way to get the id cryer;
Well Now what should i do? Any other way to get the id cryer;
You can't get the ID if there's no ID to get lol.
You could always ask your friend to add an ID to that button, and then use the getElementById method, or you could use either what I or Smiley have posted, as both of these will work for your specific case cooll;
You could always ask your friend to add an ID to that button, and then use the getElementById method, or you could use either what I or Smiley have posted, as both of these will work for your specific case cooll;
Copyright Information
Copyright © Codenstuff.com 2020 - 2023