Hi,
I am working on a simple application with a listbox and webbrowser control. I have two textboxes for username and password, and I have a button. I have some URLs in the listbox that have login forms. I need to get the username and password data from the textboxes to the related fields on the web page inside the webbrowser when the button is clicked.
I have been searching to find some samples for this but I couldn't find anything helpful. Could you direct me please.
Thanks.

4 answers
well its usually done by sending the info as a query string for some website. but in case of security you can do it in this way which might not work for some sites as well but worked for many sites. first open the login page and get all the data from it by saving it to your local pc by saving it as html. search for the place where the username textfield and password textfield are in html. set the username and password textfield value by making a value key in both fields like MYUSERNAMEFIELD and MYPASSWORDFIELD to the saved html document. then in your win form read the saved html file by System.IO.File.ReadAllText(htmlFilePath); and replace the html keys you put in the html files with the needed credentials. then add a script in the end of the webbrowser control content to click the login button when the whole html is loaded. if you find it a bit difficult set the whole thing in the html file so all you need to do is add a script in the end of the html file and set the usernamefield value to the needed credential and the same for the password and apply the login button click(), save the html file and then load the html file on the webbrowser control and it will automatically fill the textfields and the login button is clicked.
answered one year ago by:
1556
108
Thanks for the answer, as I am a total newbie it is difficult to do the exact steps you suggested in your answer, if you could lead me to an example form or code, I would be grateful. As the first step I just want to accomplish this: To pass the data from textbox(e.g., username) to the field on the web page when the button is clicked. No login required.
an example that will clear thing is this one:
answered one year ago by:
1556
Thanks again, but how can I combine the code you've given with the current one:
answered one year ago by:
108
you can merge it like this:
answered one year ago by:
1556
108
Thanks again, I will need to work on this to figure it. It is strange that I can't find one single example on the web about auto login using C# web form
1556
as u see from the example i gave u is that its not in the scope of c#, its about the html in the webpage, so all what you have to do is to control the html page by the scripts for example.