Solved

VB.NET Webbrowser Click Submit Button.

Posted on 2012-03-13
2
3,087 Views
Last Modified: 2012-03-13
Hi there, I would like to know how to click submit button on the HTML form in a webbrowser control.

HTML FORM:

<form method="POST" action="login.php">
					<table border="0" cellpadding="4" cellspacing="1" class="w12">
						<tr>
							<td>Login:</td>
							<td>
								<input type="text" name="username" class="b12">
							</td>
						</tr>
						<tr>
							<td>Password:</td>
							<td>
								<input type="password" name="password" class="b12">
							</td>
						</tr>
						<tr>
							<td colspan="2" align="right">
								<input type="submit" value="Login">
							</td>
						</tr>
					</table>
				</form>

Open in new window


PS: I have no access to the page, so I cannot change the source code, it has to work with the one above.

Thanks
0
Comment
Question by:mropenmind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 37715059
You should be able to find the element by it's type and then use InvokeMember for the click:
For Each b As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
    If b.GetAttribute("type") = "submit" Then
        b.InvokeMember("click")
    End If
Next

Open in new window


Note that if there are multiple forms with more than one submit, this would cause problems, in which case you can use a similar trick on the form itself (this is probably the better solution):

For Each b As HtmlElement In WebBrowser1.Document.GetElementsByTagName("form")
    If b.GetAttribute("action") = "login.php" Then
        b.InvokeMember("submit")
    End If
Next

Open in new window

0
 

Author Comment

by:mropenmind
ID: 37715126
Works like this:

WebBrowser1.Document.Forms(0).InvokeMember("submit")

but thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
T-SQL and CLR parameter strings 9 60
ASP.Net problem with GridView using filters and checkboxes on lines 9 39
SSIS - Using VB.NET to parse XML file 11 38
async questions 5 46
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question