473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Changing a form object in a page by using WebBrowser component?

Hi group,

Here's a problem I've been trying to solve for the past several weeks. I
have the standard WebBrowser object added to a form so it can access
websites, and I have it load a default page once the form is launched. I
now want to automatically fill out a specific text-field found within the
web-page that the WebBrowser object has open. Right now I am using the
following code to accomplish it:

webBrowser.Document.Forms(0)(1).Value = "Test Text"

But I am faced with a major complication when I use the above method. The
page in question is often changed and more form objects (hidden and visible)
are added, or the order of the form objects are changed. When this happens,
I have to manually go through and change the form position or the program
will error out or the text will be entered in the wrong text-field, when it
tries to add the text to the currently specified form object of (0)(1). To
make matters even worse, the page that loads will reflect what the user
selects previously, and depending on the selection the amount of form
objects on the page will change.

My question is... How can I simply search through the page and find the
NAME of the form-object I want to modify? For example, if the text-field I
want to insert the text into has a name of 'XYZ' in the HTML document, how
can I search through the page using Visual Basic and locate that element,
then once its found insert the correct text? The only element of the page
that I can seemingly do this with is the actual submit button, and I use the
code:

webBrowser.Document.All("Button").Click [ Will submit the form ]
webBrowser.Document.All("Button").Value = "Name of Button" [ Will change the
name of the button ]

When I try simular code to change the value of a text field, I get the
error: 'Object doesn't support this property or method'. So what is the
magical command to do what I am asking? I have searched MSDN and forums for
an answer, but all I can find is similar to the first line of code I
mentioned here. Is there a way to do this, it sounds like an easy task but
I can't get it to work! Thanks in advance,

Matt
Jul 17 '05 #1
1 6345
"Matt" <no**@thenewsgroups.com> wrote in message
news:qq********************@tznet.com...
Hi group,

Here's a problem I've been trying to solve for the past several weeks. I
have the standard WebBrowser object added to a form so it can access
websites, and I have it load a default page once the form is launched. I
now want to automatically fill out a specific text-field found within the
web-page that the WebBrowser object has open.


I think I found the answer! I'm now using code along the lines of:

webBrowser.Document.Forms(0).NameOfField.Value = "Whatever"

And that seems to have done the trick, so please disregard my initial
question. Unless of course you know of another alternative way that is even
better. I still haven't fully tested my solution, but I don't see why there
should be any problem.

Matt
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: egg | last post by:
Dear Sir/Madam, I'm about to start a project, the idea is to have a web interface to let user specify the URL of a target HTML document, based on that URL, retrieved and parsed the HTML document...
4
by: Wim Verhavert | last post by:
Hi all, For gathering certain information in building my database, I'm depending on the things I found on the web, especially one website (let's call it www.mywebsite.com). Is there a way to...
7
by: Mike | last post by:
Hi! I posted this question in browser_ctl group as well but got no results. I have a form with embedded WebBrowser. Upon clicking on a link in the embedded webbrowser that calls JavaScript's...
5
by: Mike Tadd | last post by:
I am developing a Application for a Project at Uni, and I have made a web browser on a form. It works when I have the form as its own window, but when I put it in a MDI it dorsnt work. Does anyone...
2
by: jasonhartsoe | last post by:
I'm using Visual Studio 2005 Team Edition....using visual basic. I'm trying to use the webbrowser control. In the webbrowser control I have it got to a page where there is a form. It waits for...
5
by: Kimmo Laine | last post by:
Hi is there a way to change propertys attribute from the code? Let´s say that i have the following property in my class: public int Count } Is there a way to change the displayname, from...
2
by: Matt Brown - identify | last post by:
Hello, I'm very new to this level of programming and .net in general. My background is VB. I am attempting to use the WebBrowser control to load a flash movie, and it is a known issue...
4
by: Robson Siqueira | last post by:
Folks, I am facing a problem. I am trying to manipulate the HTML data (thru the Document and DocumentText properties) of the WebBrowser object (System.Windows.Forms). The problem is that the...
6
by: Martin Slater | last post by:
Hi all, I'm using a webbrowser control within an application for the UI and want to hide the flicker and redraw when changing pages. Ideally I want to render the new page to a seperate...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.