-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
when you run into this type of situation, try to figure out what action you are trying to simulate versus the result you want (sometimes the opposite is true). In this case, you want to simulate clicking on an image. It just so happens that the result is submitting the form.
Try this code to simulate clicking the image, which in turn should fire any code attached to that image.
Code:
DirectCast(GetCurrentWebDoc.images.item("ctl00$Main$postComment$postcommentImageButton"), mshtml.HTMLImg).click()
if that name value doesn't work, try the ID instead ("ctl00_Main_postComment_postcommentImageButton")
I do hope you are making some sort of "utility", and not anything that could be used maliciously to spam comments all over myspace. ;)
What a great resource this thread has been, one of very few on the internet for this subject matter. Specific to this issue, my company now has it's own myspace page and it's my job to work it. %-(
I'm first seeing if it's feasible to do by generating this temporary test solution. I need to auto-comment anyone who sends us a comment or becomes our friend. Akin to this post, you showed how to click on an image, but I'm trying to fill in a textarea form field with your example. However, I'm running into problems. Here is the text area field data source I'm trying to automate similar to the poster above:
Code:
<textarea name="ctl00$cpMain$postComment$commentTextBox" rows="5" cols="40" id="ctl00_cpMain_postComment_commentTextBox" style="width:100%;"></textarea>
I used your source project to try and autofill the textarea box but it's not working. My test program throws an exception stating "Object reference not set to an instance of an object") It keeps telling me that I need to declare a new object. I've tried both ID & Name of control and here is a sample code I'm trying:
Code:
Public Class BuiltInBrowser
Private Sub BuiltInBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wB.Navigate("http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID=8")
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetText.Click
SetTextareaText(txtMessage.Text)
End Sub
Private Sub SetTextareaText(ByVal Text As String)
Try
DirectCast(GetCurrentWebForm.item("ctl00cpMain$postComment$commentTextBox"), mshtml.HTMLTextAreaElement).value = Text
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Function GetCurrentWebDoc() As mshtml.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Function GetCurrentWebForm() As mshtml.HTMLFormElement
Try
If GetCurrentWebDoc.forms.length > 0 Then
Return DirectCast(GetCurrentWebDoc.forms.item(0), mshtml.HTMLFormElement)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function
End Class
Any help in this matter would be GREATLY appreciated!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
OnlineNoob,
The problem MAY be that the page you are trying to manipulate has more than one form on it.
If you look at my code for GetCurrentWebForm, it checks to see if there is at least one form, and then returns that first form. However the textarea you are looking to manipulate may very well be in a second, third, or Nth form on the webpage. So you may have to modify the code to return a reference to a different form in order to manipulate the textarea on it. I believe this is mentioned in the comments in my code for that routine.
My example only grabs the first form because the example HTML page I included with the sample project only has one form, and is after all, just an example.
Check that out first, then post back with how you make out.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
hi Kleinma, thanks for your response. I added a parameter to the code to make it like the following:
Code:
Public Class BuiltInBrowser
Private Sub BuiltInBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wB.Navigate("http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID=8")
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetText.Click
SetTextareaText(txtMessage.Text)
End Sub
Private Sub SetTextareaText(ByVal Text As String)
Try
DirectCast(GetCurrentWebForm(2).item("ctl00_cpMain_postComment_commentTextBox"), mshtml.HTMLTextAreaElement).value = Text
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Function GetCurrentWebDoc() As mshtml.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Function GetCurrentWebForm(ByVal intFormNumber As Integer) As mshtml.HTMLFormElement
Try
If GetCurrentWebDoc.forms.length > 0 Then
Return DirectCast(GetCurrentWebDoc.forms.item(intFormNumber), mshtml.HTMLFormElement)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function
End Class
Amazingly enough, i only added the parameter for the function you created and set the form n8umber to the proper number and it walaa, it worked. However, i had to also change the textarea selected to use the ID of the contyrol because the name of the control didn't work. Other than that, the code workds great now. Thank you for your patience!!!!!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
glad to hear you got it working.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi Thanks for your previous help.
I'm not sure if I'm doing something silly. VS2005, I am trying to use SendKeys (and this was refered to earlier in this thread) and the control does not seem to programattically accept focus. If I click on it and type <Ctrl +a> then the page / frame is selected. Tabstop = true. The standard browser control seems to accept focus, but not the ax one. If I code:
browserCtl.focus
...sendkeys("{^}a")
No joy
Any thoughts please.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
ian,
check your PMs, but sendkeys is absolutely NOT the way to go to automate things in a browser. There are way too many hiccups and chances for error.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
This was a fantastic help and very interesting to look through. Really enjoyed. Thanks kleinma.
Incidentally, this is what i ended up coding to access frames.
Code:
Private Function GetWebFrameObject(ByVal PassDocumentObject As Object) As mshtml.HTMLWindow2
Try
Return DirectCast(PassDocumentObject, mshtml.HTMLWindow2)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Function getwebform(ByVal PassDocumentObject As mshtml.HTMLDocument) As mshtml.HTMLFormElement
Try
Return DirectCast(PassDocumentObject.forms.item(0), mshtml.HTMLFormElement)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Sub SetFrameTextBox(ByVal FrameNumber As Integer, ByVal ValueToSendToBox As String, ByVal FieldToFill As String)
DirectCast(getwebform(GetWebFrameObject(GetCurrentWebDoc().frames.item(FrameNumber)).document).item(FieldToFill, 0), mshtml.HTMLInputElement).value = ValueToSendToBox
End Sub
Private Sub clicksubmitbuttonframes(ByVal FrameNumber As Integer, ByVal FieldToFill As String)
DirectCast(getwebform(GetWebFrameObject(GetCurrentWebDoc().frames.item(FrameNumber)).document).item(FieldToFill, 0), mshtml.HTMLButtonElement).click()
End Sub
The only thing that i didn't like about how I did this was I needed to know the exact frame index number.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Using your example code I've been able to do about 80% of a project I needed to create for work. But I have one last item to figure out.
The page has 4 drop down menus on it, each with about 20 or more items. I need to programatically search for a specific word and choose the drop down item that matches in each one. How would I do that? Here is what I've got so far:
Code:
Private Sub btnComboFill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComboFill.Click
Dim MyHTMLCombo As mshtml.HTMLSelectElement = DirectCast(GetCurrentWebForm.item("ctl00_ManagementMain_FirmwareUserControl_FirmwareFilename"), mshtml.HTMLSelectElement)
Dim i As Integer
For i = 0 To MyHTMLCombo.size
If MyHTMLCombo.value.Contains(myfirmware) Then
MsgBox("I found it")
End If
Next
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kleinma
you need to use the DocumentComplete event of the webbrowser control. This event fires when a page has fully loaded. So when you do the first postback, the DocumentComplete event will fire when the page has posted back and reloaded in the browser.
I'm not sure how to use an event to handle this. For instance, say I need to navigate through 3 pages and I want it to do this all using 1 user event. How can I handle this?
1 first page load
Documentcomplete fires and I put in the second page there
second page loads
Now how do I get to the third page?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Nevermind on that second question, what I did was this (in pseudo code):
dim 1,2 as boolean = false
form load event
timer1.enabled
timer1 event
wb.navigate("webpage1")
1 = true
timer1.enabled = false
wb DocumentComplete event
if 2 = true then
wb.navigate("webpage3")
2 = false
end if
if 1 = true then
wb.navigate("webpage2")
1 = false
2 = true
end if
Thanks! although I still need help figuring out how to select those drop down items. I can use your code to figure out the index and name, but I can't select it using a word contained in an item.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
the best way to do it is to look at the webbrowsers current URL when that event fires. Then you will know what URL the user is actually viewing, so your code can take appropriate action.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by SlumberMachine
Using your example code I've been able to do about 80% of a project I needed to create for work. But I have one last item to figure out.
The page has 4 drop down menus on it, each with about 20 or more items. I need to programatically search for a specific word and choose the drop down item that matches in each one. How would I do that? Here is what I've got so far:
Code:
Private Sub btnComboFill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComboFill.Click
Dim MyHTMLCombo As mshtml.HTMLSelectElement = DirectCast(GetCurrentWebForm.item("ctl00_ManagementMain_FirmwareUserControl_FirmwareFilename"), mshtml.HTMLSelectElement)
Dim i As Integer
For i = 0 To MyHTMLCombo.size
If MyHTMLCombo.value.Contains(myfirmware) Then
MsgBox("I found it")
End If
Next
Well I solved this problem, here is the solution:
Code:
Dim MyHTMLCombo As mshtml.HTMLSelectElement = DirectCast(GetCurrentWebForm.item("ctl00_ManagementMain_FirmwareUserControl_FirmwareFilename"), mshtml.HTMLSelectElement)
Dim total As Integer
total = MyHTMLCombo.length
Dim i As Integer
For i = 0 To total
MyHTMLCombo.selectedIndex = i
If MyHTMLCombo.value.Contains("what im looking for") Then
found = True
Exit For
End If
Next
Yeah!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
looks good, but you should really do your loop
for i = 0 to (total - 1)
Since the total is the total number of items, and the indexes start at 0, your loop should be 0 to the total - 1.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
This article was awesome and I learned a ton, but I have come to something a little too much for me to figure out, i am trying to navigate to a url, select all of the checkboxes, and then run a javascript code that will download them. The issue is that the table with item names, numbers, and the checkboxes seem to be done on the serverside and then just pushed to the screen so i see no id's or names for any of the check boxes. There is an image thats click event selects them all but i cannot get it clicked. Here is the source code for it:
<td class='headerbar' nowrap width='4%' align='center' id=0><img OnClick='JobTable.MarkAll()' src='images/checker.gif' width=15 style='cursor:hand'></td>
plus i would like to know how to access the table, but one thing at a time. Thanks
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Better still, clicking that image fires a function:
function MarkAll()
I am trying this:
GetCurrentWebDoc.parentWindow.execScript("markall()", "javascript")
and getting this error:
Exception from HRESULT: 0x80020101
any idea what i could be doing wrong?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
it looks like the MarkAll function is linked up with the JobTable object since the onClick method is calling JobTable.MarkAll();
So if something like this doesn't work:
Code:
GetCurrentWebDoc.parentWindow.execScript("JobTable.MarkAll()", "javascript")
then you have to go the route of tracking down the image and clicking it. This is very easy if the image has an ID or NAME property to associate with it. Based on your HTML code above though, this image has neither, so the only thing you can do is loop the images, narrow down to the one you want, and then invoke its click method, something like this SHOULD work:
Code:
Dim MyImage As mshtml.HTMLImg = Nothing
For i As Integer = 0 To GetCurrentWebDoc.images.length - 1
MyImage = DirectCast(GetCurrentWebDoc.images.item(, i), mshtml.HTMLImg)
If MyImage.src.ToLower = "images/checker.gif" And MyImage.style.cursor = "hand" Then
MyImage.click()
Return
End If
Next
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Thanks, the first line worked like a charm. One more question, I have this code which will let me select a file, and gives info about that file, i would like to pass a row number and return the various values at the bottom of the code. Some thing like:
for i=1 to max rows
getrow(i).jobid.value
next
Here is the code
function GetRow(id)
document.RowSelected.JobId.value = JodIdArray[id];
document.RowSelected.Status.value = StatusArray[id];
document.RowSelected.Extension.value = FileExtArray[id];
document.RowSelected.Filename.value = FileNameArray[id];
document.RowSelected.ReqName.value = ReqNameArray[id];
off to other code...
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I read the whole thread and I can't find a solution for my problem.
What I'm doing wrong? If anyone can help me.
I want to submit username and password to this form http://iptv.bg/watch
but I can't get it work.
Here is my code (I'm using VB 6.0 and mshtml control):
Code:
Private Sub IPTVLogin()
Dim objMSHTML As New MSHTMLCtl.HTMLDocument
Dim objdoc As New MSHTMLCtl.HTMLDocument
Set objdoc = objMSHTML.createDocumentFromUrl("http://iptv.bg/watch", vbNullString)
While objdoc.readyState <> "complete"
DoEvents
Wend
If InStr(1, objdoc.body.innerHTML, "Вход") <> 0 Then
With objdoc
.All.Item("login").Value = "username"
.All.Item("password").Value = "password"
.Forms(0).submit
End With
End If
End Sub
and here is the some part of the code used in that web page (they use javascript for the login, I think)
Code:
<div class="formtable_login">
<form method="post" action="/watch" name="loginform" onsubmit="return hash_password(this)">
<input type="hidden" name="save" value="1" />
<input type="hidden" name="go" value="index.php" />
<table border="0" cellpadding="3" cellspacing="0" class="formtable">
<tr>
<td width="30%" align="right"><label for="login">Е-мейл адрес</label></td>
<td width="70%"><input type="text" id="login" name="login" value="" maxlength="64" size="32" class="txt" /></td>
</tr>
<tr>
<td align="right"><label for="password">Парола</label></td>
<td><input type="password" id="password" name="password" value="" maxlength="64" size="32" class="txt" /></td>
</tr>
<tr>
<td align="right"><br /></td>
<td><label><input type="checkbox" name="rme" value="1" class="chk" /> Запомни ме на този компютър</label></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value=" Вход в IPTV.bg " class="input_submit" /></td>
</tr>
</table>
</form>
</div>
If anyone can help me I'll be grateful :)
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Any idea how to get the source code of the frame object? I can't seem to get this one.
Quote:
Originally Posted by demausdauth
This was a fantastic help and very interesting to look through. Really enjoyed. Thanks kleinma.
Incidentally, this is what i ended up coding to access frames.
Code:
Private Function GetWebFrameObject(ByVal PassDocumentObject As Object) As mshtml.HTMLWindow2
Try
Return DirectCast(PassDocumentObject, mshtml.HTMLWindow2)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Function getwebform(ByVal PassDocumentObject As mshtml.HTMLDocument) As mshtml.HTMLFormElement
Try
Return DirectCast(PassDocumentObject.forms.item(0), mshtml.HTMLFormElement)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Sub SetFrameTextBox(ByVal FrameNumber As Integer, ByVal ValueToSendToBox As String, ByVal FieldToFill As String)
DirectCast(getwebform(GetWebFrameObject(GetCurrentWebDoc().frames.item(FrameNumber)).document).item(FieldToFill, 0), mshtml.HTMLInputElement).value = ValueToSendToBox
End Sub
Private Sub clicksubmitbuttonframes(ByVal FrameNumber As Integer, ByVal FieldToFill As String)
DirectCast(getwebform(GetWebFrameObject(GetCurrentWebDoc().frames.item(FrameNumber)).document).item(FieldToFill, 0), mshtml.HTMLButtonElement).click()
End Sub
The only thing that i didn't like about how I did this was I needed to know the exact frame index number.
-
1 Attachment(s)
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Take a look at this to see the frames source.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi kleinma,
This site is the best source for web page manipulation using GetCurrentWebDoc. I have been using your code to manipulate few sites. But some how I can't access any links, frame or any type of tag for this (http://www.insidercow.com/) site. I get the counts as "0" for all the tags.
I am using a similar code like below.
Dim otr As mshtml.IHTMLElementCollection = GetCurrentWebDoc.getElementsByTagName("table")
But a web page related to the above web site (http://206.222.29.162/winners.jsp), I do lot of manipulation using your example codes.
Advance thanks.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Quote:
Originally Posted by kumartech
Hi kleinma,
This site is the best source for web page manipulation using GetCurrentWebDoc. I have been using your code to manipulate few sites. But some how I can't access any links, frame or any type of tag for this (
http://www.insidercow.com/) site. I get the counts as "0" for all the tags.
I am using a similar code like below.
Dim otr As mshtml.IHTMLElementCollection = GetCurrentWebDoc.getElementsByTagName("table")
But a web page related to the above web site (
http://206.222.29.162/winners.jsp), I do lot of manipulation using your example codes.
Advance thanks.
Kumartech,
that site is a bit odd, in that it uses a single frame page. So getting the current web doc using the function in my code simply returns the frames page, and not the frame document itself. So you can use this code, to grab the frame, and then grab the document from that frame.
Code:
Dim mainFrame As mshtml.HTMLWindow2 = DirectCast(GetCurrentWebDoc.frames.item(0), mshtml.HTMLWindow2)
Dim CurrentWebDoc As mshtml.HTMLDocument = DirectCast(mainFrame.document, mshtml.HTMLDocument)
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I am trying to automate a process that involves repetitive access to a website after loggins on.
I have downloaded and reviewed the kleinma example and I am having trouble just getting started.
I am getting the error message
Message "Unable to cast object of type 'System.Windows.Forms.HtmlDocument' to type 'mshtml.HTMLDocument'." String
in the GetCurrentWebDoc function.
My code is just getting started but is posted below...
Public Class Form3
Private Sub Form3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
wb.Navigate("http://www.njmmis.com/login.aspx")
End Sub
'FILLS THE HTML TEXTBOX WITH TEXT FROM OUR WINFORM
Private Sub SetTextboxText(ByVal Text As String)
DirectCast(GetCurrentWebForm.item("txtBox"), mshtml.HTMLInputElement).value = Text
End Sub
'ALL THIS FUNCTION DOES IS GRABS THE CURRENT DOCUMENT FROM THE WEBBROWSER CONTROL
'AND CONVERTS IT TO THE STRONG TYPED mshtml.HTMLDocument CLASS
'THIS SAVES CODE BECAUSE YOU NEED TO GET THE WEB DOC FOR ALL CASES OF MANIPULATION
Private Function GetCurrentWebDoc() As mshtml.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
'SAME AS THE ABOVE FUNCTION, EXCEPT IT GRABS A WEBFORM. I ASSUME HERE THERE IS ONLY 1 FORM
'IF YOU WERE DEALING WITH A PAGE WITH MULTIPLE FORMS, SIMPLY USE ITS INDEX (THEY ARE IN AN ARRAY)
'THIS IS A USEFUL METHOD BECAUSE OFTEN TIMES WHEN MANIPULATING A WEBPAGE, ITS TO GET/SET DATA IN A FORM
Private Function GetCurrentWebForm() As mshtml.HTMLFormElement
Try
If GetCurrentWebDoc.forms.length > 0 Then
Return DirectCast(GetCurrentWebDoc.forms.item(0), mshtml.HTMLFormElement)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function
Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DirectCast(GetCurrentWebForm.item("txtUserName"), mshtml.HTMLInputElement).value = "xxxxxxxl"
End Sub
End Class
Any direction would be most appreciated.
I am using VS2005.
Thanks,
~Ken
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
My example code using the COM based webbrowser control. Prior to VS2005 there was no built in webbrowser control in the toolbox. So you had to use the COM one.
I am actually in the process of retooling this sample here to be exclusive with the 2005 managed browser control (well slightly extended) instead of the COM based one, but its going to have to wait until I finish up a few important projects.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Matt,
What am I missing?
I thought I was using the com based control.
I included a reference to the Microsoft Internet Control 1.1.0.0 COm object.
I even copied the actual control on the window from the sample code.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
what line of code exactly gives you the error?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
i'm having problems getting the source code of a site that i navigated to with the webbrowser
i get this error "Object reference not set to an instance of an object."
on this line F.txtSource.Text = GetCurrentWebDoc.documentElement.outerHTML
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
that error just means something is evaluating to null (nothing)
either GetCurrentWebDoc, documentElement, or outerHTML is equal to nothing when you call that. Figuring out which one, would be the first step to getting it working.
Since you didn't give the actual URL, I can't really advise any further.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi!
In your example i see that you get the value from combo box
But i need to set value in combo box how can i do that?
thank for answer
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
To set a combobox, you can either set the selectedindex value of it to the desired index you want, or you can set the value to whatever value you want
Obviously either the selectedindex or the value has to be a valid one (ie you can't specify a value that doesn't exist in the list)
Also remember that a value is NOT the same thing as what is displayed in a combobox.
Combobox HTML code looks like
Code:
<select id=cmboSelect>
<option value=""></option>
<option value="a">Apples</option>
<option value="o">Oranges</option>
</select>
so if you wanted to set Apples you would need to set the value of the combo to "a"
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
i would like to set both text displayed and the value. Is this even possible?
I would like to pass somekind array of parameters
something like
ParamName=value
so i was thinking that ParaName can be Value in combobox and the Value of param Could be the textdisplayed of combobox.Cause i only need this to pass data.
SO is there any other chances or possibilities to pass that kind of data, combobox would be great cause i have more than 1 parameter and i would not like to parse string in textbox
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
if you don't know the value, and only know the text you want to set, you need to loop through the "options" elements inside the select element until you find the one thats innertext value matches what you want, and then set that option as the selected option
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
i know both in my program paramName and value
Can you give me any example for VB6, on how to do that!
I acees to textbox like this WebBrowser1.document.GetElementById("txtPrintFormName").Value
so how can i access to combobox
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
it should be the same way, but using the combobox name instead of the textbox name.
I haven't coded in VB6 for a few years now, so I am not sure if there is anything additional to consider. As you probably know, this entire thread is focused on VB.NET
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi!
This is how it goes set the combobox in VB6
WebBrowser1.Document.GetElementById("DropDParam").Options(0).Text = "hmmmmmmmmmmmmmmmmmmmmmmmmmmm"
WebBrowser1.Document.GetElementById("DropDParam").Options(0).Value = "123"
But now i have another problem, when i click my go button on page
(code click event in my webpage)
String text = DropDParam.Items[0].Text;
it takes the default value from combobox, not the value i set in vb6 webbrowser control
i also must include this in web.config <pages enableEventValidation="false"/>
if i don't when i click on button it give me next error:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi i'm quite a noob, and what i want to do is extract a table from http://www.handelsblatt.com/News/def...ymbol=FLUK.NWX and save it as xls or txt. when i tried your project i recieved an error: " Name 'GetCurrentWebForm' is not declared ".
so why this error?
and where exactly do i find the code to extract?
and how do i save that to a file?
finally: how do i click a link ("weiter" at the bottom right of the table)
(hope i didnt ask something that has already been answered)
well, thanks in advance!
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
I'm having severe difficulties with a slightly more exotic (but similar) issue...
If anyone's able to shed some light, please let me know here:
http://www.vbforums.com/showthread.p...36#post3078736
-
1 Attachment(s)
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
This has been a great learning tool.
Thanks a lot.
I also have the similar problem.
I want to enter the username and password into a form which is a Citrix MetraFrame XP page.
basically it's a Citrix page which gives access to some other box but we want to use Windows Credentials rather than citrix username/password. So what we are trying to do is, having a middle layer (vb.net app) which will load the citrix page behind the scenes. After authenticating with the windows credentials of the User, the page will fill in the citrix username/password and hit the login button.
I tried your code and the application you have provided (WebPageManipulation) but it falls over at GetCurrentWebForm function.
I investigated and found that Document Object doesn't have any forms in it or probably it's increpted. (i'm not sure) but the Document.Forms.Length always returns 0.
I have attached the file with this thread.
please take a look at it.
thanks
RJ
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
RJ,
That MHT file was not viewable in IE, however I did look at the source and there is defenitly a form there.
Its name is 3DNFuseForm.
Without seeing workable source, it is hard for me to really advise further.
Are you sure that there are no frames being used?
-
Re: Manipulate/Change/Form Fill data in webpages using the Webbrowser control
Hi Kleinma,
I've been looking through everything here and didn't see an answer to my question below, or I missed it somewhere.
I have a link I want to click but it has no id or tagname. It does have a 'href' and so in order to click it I want to try to loop through the links until I get my one using the code below.
Code:
For Each element As HtmlElement In WebBrowser.Document.Links
If element.GetAttribute("href").Contains("Call_Detail_Records") Then
element.InvokeMember("Click")
Exit For
End If
Next
Problem is that when it's looping it loops through the other links on the page but doesn't loop through the the three links in the centre of the page so it never reaches the call detail records link. By reading this forum my guess might be that it is in it's own form or something like that?
I am using IE Developer Toolbar to look at the webpages so that I can see what the id's, tag names etc are and it is very useful. But, it doesn't seem to allow me to identify forms, or at least I haven't figured that out yet. So, my question is, how can I know what forms are on the page? And secondly, why did the link I was looking for not get included in the WebBrowser.Document.Links object?
Thanks, JF :wave: