473,322 Members | 1,523 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,322 software developers and data experts.

Automating dialog with web server from VB.NET

I am attempting to programatically drive a Lotus Notes web application
from a VB.NET database application (who wants to rekey information in
one database into someone else's web page for entry to theirs?). I am
using the System.Net.WebClient to communicate with the LotusNotes
server. It is not clear if I should be instantiating a new object for
each communication, or persisting the initial one.

based on the input values in the web page,

<INPUT NAME="Name" VALUE="" ...
<INPUT NAME="Password" VALUE="" ...

I have established the following code:

Dim myNameValueCollection As New
System.Collections.Specialized.NameValueCollection

myNameValueCollection.Add("Name", txtMyUserName.Text)
myNameValueCollection.Add("Password",
txtMyUserPassword.Text)

Dim uriString as String = "/names.nsf?Login"
Dim myWebClient As New System.Net.WebClient

' Upload the NameValueCollection.
Dim responseArray As Byte() =
myWebClient.UploadValues(uriString, "POST", myNameValueCollection)
The application web page contains

<FORM METHOD=post ACTION="/names.nsf?Login"
NAME="_DominoForm">

When I run this, the response I get is a return of the login web page
(ie: login failed), so I assume I'm missing something.

Any suggestions?

thanks,
Mark Gross mg****@deq.state.id.us
PS: This application used to be run using 3270 terminal emulation screen
scraping in VB6. Now that the mainframe folks are moving to web based
applications, I have to migrate with them because they still won't allow
flat file submissions... some things haven't changed all that much.

Nov 20 '05 #1
19 3945
Hi Mark,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to post some data to a
names.nsf page.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Since I have no Lotus Notes web application at hand, I test on an aspx page.
Here is my code on client.
Imports System.Net
Imports System.Collections.Specialized
Imports System.Text
Module Module1
Sub Main()
'Dim o As New TestCls.TestABC
'Console.WriteLine(o.Hello)
Console.Write(ControlChars.Cr + "Please enter the URL to post data
to : ")
Dim uriString As String =
"http://localhost/WebApplication6/WebForm1.aspx"
' Create a new WebClient instance.
Dim myWebClient As New WebClient
' Create a new NameValueCollection instance to hold some custom
parameters to be posted to the URL.
Dim myNameValueCollection As New NameValueCollection
Console.WriteLine("Please enter the following parameters to be
posted to the Url")
Console.Write("Name:")
Dim name As String = "TestUser"
Console.Write("Age:")
Dim age As String = ""
Console.Write("Address:")
Dim address As String = ""
' Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name", name)
myNameValueCollection.Add("Address", address)
myNameValueCollection.Add("Age", age)
Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...",
uriString)
' Upload the NameValueCollection.
Dim responseArray As Byte() = myWebClient.UploadValues(uriString,
"POST", myNameValueCollection)
' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :" +
ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))
End Sub
End Module

[aspx codebehind page]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Request.Form("Name") = "TestUser" Then
Response.Write("OK")
End If
End Sub

You may try my code first with an aspx page first to isolate the problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
Hi Mark,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to post some data to a
names.nsf page.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Since I have no Lotus Notes web application at hand, I test on an aspx page.
Here is my code on client.
Imports System.Net
Imports System.Collections.Specialized
Imports System.Text
Module Module1
Sub Main()
'Dim o As New TestCls.TestABC
'Console.WriteLine(o.Hello)
Console.Write(ControlChars.Cr + "Please enter the URL to post data
to : ")
Dim uriString As String =
"http://localhost/WebApplication6/WebForm1.aspx"
' Create a new WebClient instance.
Dim myWebClient As New WebClient
' Create a new NameValueCollection instance to hold some custom
parameters to be posted to the URL.
Dim myNameValueCollection As New NameValueCollection
Console.WriteLine("Please enter the following parameters to be
posted to the Url")
Console.Write("Name:")
Dim name As String = "TestUser"
Console.Write("Age:")
Dim age As String = ""
Console.Write("Address:")
Dim address As String = ""
' Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name", name)
myNameValueCollection.Add("Address", address)
myNameValueCollection.Add("Age", age)
Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...",
uriString)
' Upload the NameValueCollection.
Dim responseArray As Byte() = myWebClient.UploadValues(uriString,
"POST", myNameValueCollection)
' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :" +
ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))
End Sub
End Module

[aspx codebehind page]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Request.Form("Name") = "TestUser" Then
Response.Write("OK")
End If
End Sub

You may try my code first with an aspx page first to isolate the problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3
Peter,

My application is a Windows form, using VB.NET. The target web application
that I wish to control is a Lotus Notes application, served from a Domino
server.
I have used the example provided below, and it does not succeed for me. Part
of the problem was learning how to handle the firewall proxy server.

The folks at Dart.Com (PowerTCP) have a web address which posts back whatever
parameters you send it, and it appears I am sending everything correctly.

I am uncertain however about a couple of things. I download the initial dialog
web
page which contains the following:

<FORM METHOD=post ACTION="/names.nsf?Login" NAME="_DominoForm">

I a using the ACTION value to post back to. Do I need to do anything with the
NAME value?

<INPUT TYPE=hidden NAME="%%ModDate" VALUE="0000000000000000">

In parsing this out, is "%%" supposed to be replaced by something, or returned
literally?

<INPUT NAME="RedirectTo" VALUE="/defaultweb.nsf/mainframeset.htm"
type=hidden></FORM>

If this is a redirect, is there anything special that needs to be done in
retrieving the results?

Thanks for your help,
mark
Peter Huang wrote:
Hi Mark,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to post some data to a
names.nsf page.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Since I have no Lotus Notes web application at hand, I test on an aspx page.
Here is my code on client.
Imports System.Net
Imports System.Collections.Specialized
Imports System.Text
Module Module1
Sub Main()
'Dim o As New TestCls.TestABC
'Console.WriteLine(o.Hello)
Console.Write(ControlChars.Cr + "Please enter the URL to post data
to : ")
Dim uriString As String =
"http://localhost/WebApplication6/WebForm1.aspx"
' Create a new WebClient instance.
Dim myWebClient As New WebClient
' Create a new NameValueCollection instance to hold some custom
parameters to be posted to the URL.
Dim myNameValueCollection As New NameValueCollection
Console.WriteLine("Please enter the following parameters to be
posted to the Url")
Console.Write("Name:")
Dim name As String = "TestUser"
Console.Write("Age:")
Dim age As String = ""
Console.Write("Address:")
Dim address As String = ""
' Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name", name)
myNameValueCollection.Add("Address", address)
myNameValueCollection.Add("Age", age)
Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...",
uriString)
' Upload the NameValueCollection.
Dim responseArray As Byte() = myWebClient.UploadValues(uriString,
"POST", myNameValueCollection)
' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :" +
ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))
End Sub
End Module

[aspx codebehind page]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Request.Form("Name") = "TestUser" Then
Response.Write("OK")
End If
End Sub

You may try my code first with an aspx page first to isolate the problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #4
Peter,

My application is a Windows form, using VB.NET. The target web application
that I wish to control is a Lotus Notes application, served from a Domino
server.
I have used the example provided below, and it does not succeed for me. Part
of the problem was learning how to handle the firewall proxy server.

The folks at Dart.Com (PowerTCP) have a web address which posts back whatever
parameters you send it, and it appears I am sending everything correctly.

I am uncertain however about a couple of things. I download the initial dialog
web
page which contains the following:

<FORM METHOD=post ACTION="/names.nsf?Login" NAME="_DominoForm">

I a using the ACTION value to post back to. Do I need to do anything with the
NAME value?

<INPUT TYPE=hidden NAME="%%ModDate" VALUE="0000000000000000">

In parsing this out, is "%%" supposed to be replaced by something, or returned
literally?

<INPUT NAME="RedirectTo" VALUE="/defaultweb.nsf/mainframeset.htm"
type=hidden></FORM>

If this is a redirect, is there anything special that needs to be done in
retrieving the results?

Thanks for your help,
mark
Peter Huang wrote:
Hi Mark,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to post some data to a
names.nsf page.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Since I have no Lotus Notes web application at hand, I test on an aspx page.
Here is my code on client.
Imports System.Net
Imports System.Collections.Specialized
Imports System.Text
Module Module1
Sub Main()
'Dim o As New TestCls.TestABC
'Console.WriteLine(o.Hello)
Console.Write(ControlChars.Cr + "Please enter the URL to post data
to : ")
Dim uriString As String =
"http://localhost/WebApplication6/WebForm1.aspx"
' Create a new WebClient instance.
Dim myWebClient As New WebClient
' Create a new NameValueCollection instance to hold some custom
parameters to be posted to the URL.
Dim myNameValueCollection As New NameValueCollection
Console.WriteLine("Please enter the following parameters to be
posted to the Url")
Console.Write("Name:")
Dim name As String = "TestUser"
Console.Write("Age:")
Dim age As String = ""
Console.Write("Address:")
Dim address As String = ""
' Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name", name)
myNameValueCollection.Add("Address", address)
myNameValueCollection.Add("Age", age)
Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...",
uriString)
' Upload the NameValueCollection.
Dim responseArray As Byte() = myWebClient.UploadValues(uriString,
"POST", myNameValueCollection)
' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :" +
ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))
End Sub
End Module

[aspx codebehind page]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Request.Form("Name") = "TestUser" Then
Response.Write("OK")
End If
End Sub

You may try my code first with an aspx page first to isolate the problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #5
Hi Mark,

I t hink you may try to post the hidden value(%%ModDate and RedirectTo) to
the webpage in addition to Name and Password to see if the problem persists.
That is to say you may try to post four namevalues at least to the server.

You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #6
Hi Mark,

I t hink you may try to post the hidden value(%%ModDate and RedirectTo) to
the webpage in addition to Name and Password to see if the problem persists.
That is to say you may try to post four namevalues at least to the server.

You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #7
Hi Mark,

Have your tried my suggestion that try to post the hidden values to the
server side togother with the name and password?
I write the post just to want to know if the problem persists.
If you still have any concern on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #8
Peter,

Apologies for taking a while to get back to you; I work two jobs and my wife is
undergoing chemotherapy for a very rare form of leukemia, and I've not been on
a single thread very successfully for a while...

Turns out my problem was I was posting to the address of the original source
page instead of the address in the HTML <FORM ACTION="/names.nsf?Login">

-when I send it there it successfully returns the next page, which
unfortunately is a frame.

Here is a question to follow this: How does one handle frames? The returned
page is very brief, consisting of two frames referencing two different URLs. I
would assume that there must be a way to:

retrieve main URL frame code
do until
retrieve subframe URL page code
done

all within the context of the validated parent frame? If you can help with
this, I'd be delighted!

Best regards,
Mark
Peter Huang wrote:
Hi Mark,

Have your tried my suggestion that try to post the hidden values to the
server side togother with the name and password?
I write the post just to want to know if the problem persists.
If you still have any concern on this issue, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #9
Hi Mark,

I am sorry to hear that.
Hope your wife will recover soon.

As for the question that retrieve the frame src, because the security
concern, we can not use the mshtml library to access the frame's property
directly.
As a workaround, we have to access the WebBrowser object model of frame
windows in an HTML page inside the control by using the IOleContainer
interface.

e.g. the html file we got from the post operation is as below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>Nested Hierarchy Frameset</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</head>
<frameset cols="150,*">
<frame name="left" src="http://www.google.com" scrolling="no" noresize>
<frameset rows="20%,*">
<frame name="rtop" src="http://www.microsoft.com">
<frame name="rbottom" src="http://www.yahoo.com">
</frameset>
<noframes>
<p id="p1">
This HTML frameset displays multiple Web pages. To view this frameset,
use a Web browser that supports HTML 4.0 and later.
</p>
</noframes>
</frameset>
</html>
Here is the VB.NET code to get the Frame URL.
We may need to add an WebBrowser control onto the form to achieve out goal,
but we can make the control invisible.

1. We need to declare some interface.

Imports System.Runtime.InteropServices
<ComVisible(True), Guid("0000011B-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Interface IOleContainer
Sub ParseDisplayName(<[In](), MarshalAs(UnmanagedType.Interface)> ByVal
pbc As [Object], <[In](), MarshalAs(UnmanagedType.BStr)> ByVal
pszDisplayName As [String], <Out(), MarshalAs(UnmanagedType.LPArray)> ByVal
pchEaten() As Integer, <Out(), MarshalAs(UnmanagedType.LPArray)> ByVal
ppmkOut() As [Object])
Function EnumObjects(<[In](), MarshalAs(UnmanagedType.U4)> ByVal
grfFlags As Integer, <Out()> ByRef ppenum As IEnumUnknown) As Integer
Sub LockContainer(<[In](), MarshalAs(UnmanagedType.I4)> ByVal fLock As
Integer)
End Interface 'IOleContainer
Public Enum tagOLECONTF
EMBEDDINGS = 1
LINKS = 2
OTHERS = 4
ONLYUSER = 8
ONLYIFRUNNING = 16
End Enum
<ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("00000100-0000-0000-C000-000000000046")> _
Public Interface IEnumUnknown
<PreserveSig()> _
Function [Next](ByVal celt As Integer,
<MarshalAs(UnmanagedType.IUnknown)> ByRef rgelt As [Object], ByRef
pceltFetched As Integer) As Integer
<PreserveSig()> _
Function Skip(ByVal celt As Integer) As Integer
<PreserveSig()> _
Function Reset() As Integer
<PreserveSig()> _
Function Clone(ByRef ppenum As IEnumUnknown) As Integer
End Interface

2. We use the WebBrowser control to load the html file we get from the
post operation and save to harddisk( we note it as test.html)

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.AxWebBrowser1.Visible = False
Me.AxWebBrowser1.Navigate("c:\test.html")
End Sub

Private Sub AxWebBrowser1_DownloadComplete(ByVal sender As Object,
ByVal e As System.EventArgs) Handles AxWebBrowser1.DownloadComplete
MsgBox("Download complele")
End Sub

3. After the the document has been downloaded, we can run the code below to
get the urls.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim pContainer As IOleContainer '
Dim o As IEnumUnknown
Dim pEnumerator As IEnumUnknown
Dim pUnk As Object
Dim pBrowser As SHDocVw.IWebBrowser2
pContainer = CType(Me.AxWebBrowser1.Document, IOleContainer)
' Get an enumerator for the frames
If pContainer.EnumObjects(tagOLECONTF.EMBEDDINGS, pEnumerator) = 0
Then
pContainer = Nothing
Dim pceltFetched As Integer = 0
' Enumerate and refresh all the frames
Do While pEnumerator.Next(1, pUnk, pceltFetched) = 0
Try
If IsNothing(pUnk) Then
Exit Do
End If
' Get the IWebBrowser2 interface
pBrowser = pUnk
Debug.WriteLine("Frame: " & pBrowser.LocationURL)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
pceltFetched = 0
Loop
pEnumerator = Nothing
End If
End Sub
4. Now we have the urls of the three frames, we can use the Webclient use
the download and save the content.
Here is the link about how to downloads data from a resource with the
specified URI to a local file.

WebClient.DownloadFile Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnetwebclientclassdownloadfiletopic.asp

You may try my suggestion and let me know the result.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #10
Peter,

Thank you very much. This will keep me busy for a while. I appreciate the
guidance.

My wife had a rough night last night with a bad reaction to the chemotherapy (ICE -
ifosomide/carboplatin/etopocide) which has to be administered over 3 days in the
hospital. Although the leukemia is terminal and swift, she is actually responding
to treatment and gaining strength. We are grateful for each day.

thank you again,
mark

Peter Huang wrote:
Hi Mark,

I am sorry to hear that.
Hope your wife will recover soon.

As for the question that retrieve the frame src, because the security
concern, we can not use the mshtml library to access the frame's property
directly.
As a workaround, we have to access the WebBrowser object model of frame
windows in an HTML page inside the control by using the IOleContainer
interface.

e.g. the html file we got from the post operation is as below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>Nested Hierarchy Frameset</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</head>
<frameset cols="150,*">
<frame name="left" src="http://www.google.com" scrolling="no" noresize>
<frameset rows="20%,*">
<frame name="rtop" src="http://www.microsoft.com">
<frame name="rbottom" src="http://www.yahoo.com">
</frameset>
<noframes>
<p id="p1">
This HTML frameset displays multiple Web pages. To view this frameset,
use a Web browser that supports HTML 4.0 and later.
</p>
</noframes>
</frameset>
</html>

Here is the VB.NET code to get the Frame URL.
We may need to add an WebBrowser control onto the form to achieve out goal,
but we can make the control invisible.

1. We need to declare some interface.

Imports System.Runtime.InteropServices
<ComVisible(True), Guid("0000011B-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Interface IOleContainer
Sub ParseDisplayName(<[In](), MarshalAs(UnmanagedType.Interface)> ByVal
pbc As [Object], <[In](), MarshalAs(UnmanagedType.BStr)> ByVal
pszDisplayName As [String], <Out(), MarshalAs(UnmanagedType.LPArray)> ByVal
pchEaten() As Integer, <Out(), MarshalAs(UnmanagedType.LPArray)> ByVal
ppmkOut() As [Object])
Function EnumObjects(<[In](), MarshalAs(UnmanagedType.U4)> ByVal
grfFlags As Integer, <Out()> ByRef ppenum As IEnumUnknown) As Integer
Sub LockContainer(<[In](), MarshalAs(UnmanagedType.I4)> ByVal fLock As
Integer)
End Interface 'IOleContainer
Public Enum tagOLECONTF
EMBEDDINGS = 1
LINKS = 2
OTHERS = 4
ONLYUSER = 8
ONLYIFRUNNING = 16
End Enum
<ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown ),
Guid("00000100-0000-0000-C000-000000000046")> _
Public Interface IEnumUnknown
<PreserveSig()> _
Function [Next](ByVal celt As Integer,
<MarshalAs(UnmanagedType.IUnknown)> ByRef rgelt As [Object], ByRef
pceltFetched As Integer) As Integer
<PreserveSig()> _
Function Skip(ByVal celt As Integer) As Integer
<PreserveSig()> _
Function Reset() As Integer
<PreserveSig()> _
Function Clone(ByRef ppenum As IEnumUnknown) As Integer
End Interface

2. We use the WebBrowser control to load the html file we get from the
post operation and save to harddisk( we note it as test.html)

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.AxWebBrowser1.Visible = False
Me.AxWebBrowser1.Navigate("c:\test.html")
End Sub

Private Sub AxWebBrowser1_DownloadComplete(ByVal sender As Object,
ByVal e As System.EventArgs) Handles AxWebBrowser1.DownloadComplete
MsgBox("Download complele")
End Sub

3. After the the document has been downloaded, we can run the code below to
get the urls.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim pContainer As IOleContainer '
Dim o As IEnumUnknown
Dim pEnumerator As IEnumUnknown
Dim pUnk As Object
Dim pBrowser As SHDocVw.IWebBrowser2
pContainer = CType(Me.AxWebBrowser1.Document, IOleContainer)
' Get an enumerator for the frames
If pContainer.EnumObjects(tagOLECONTF.EMBEDDINGS, pEnumerator) = 0
Then
pContainer = Nothing
Dim pceltFetched As Integer = 0
' Enumerate and refresh all the frames
Do While pEnumerator.Next(1, pUnk, pceltFetched) = 0
Try
If IsNothing(pUnk) Then
Exit Do
End If
' Get the IWebBrowser2 interface
pBrowser = pUnk
Debug.WriteLine("Frame: " & pBrowser.LocationURL)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
pceltFetched = 0
Loop
pEnumerator = Nothing
End If
End Sub

4. Now we have the urls of the three frames, we can use the Webclient use
the download and save the content.
Here is the link about how to downloads data from a resource with the
specified URI to a local file.

WebClient.DownloadFile Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnetwebclientclassdownloadfiletopic.asp

You may try my suggestion and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #11
Me.AxWebBrowser1.Visible = False
Me.AxWebBrowser1.Navigate("c:\test.html")

Peter,

In simulating this, I also must authenticate to a proxy server. Can I set the
globalProxySelection.Select as when using the System.Net.WebClient, or how do I do
authenticate to a proxy server with AxWebBrowser?

This is a bit obscure.
Many thanks,
mark

Nov 20 '05 #12
Hi Mark,

Thanks for keeping me posted.
I understand how difficult these times are for you both, and I sincerely
hope that your wife continues to respond well to her treatment .

First I agree with that we can use the GlobalProxySelection when using
WebClient. WebClient class use WebRequest class to access the internet.
Therefore you can use GlobalProxySelection class to select a global proxy.
Then the proxy will also be used by WebClient. More information about the
proxy, please check the reference of Proxy property of HttpWebRequest class.

HttpWebRequest.Proxy Property
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemNetHttpWebRequestClassProxyTopic.asp

As for the Webbrowser control, its behavior is similar with the internet
explorer. When we access a website via an authentication proxy, it will
popup a dialog to input the credential. My suggestion is to save the html
file with frame to the local disk and then load it into the webbrowser from
local so that we do not need to handle the authentication in the WebBrowser.
If you feel the approach is somewhat tedious, I think you may try to parse
the html file returned back manually when you post the username password to
the login website. So that we do not need to use the WebBrowser control.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #13
Peter,

Thank you for your suggestions. I may end up using a combination of WebClient
and WebBrowser.
I have a functioning login dialog with the target server that uses WebClient.
Unfortunately, the return from the server after authentication is a frame page,
so in order to perform the automated dialog within the frame I will need to use
the WebBrowser control. I am making the assumption that using the WebBrowser I
can initiate a POST with a set of named paremeters. This gives the double
benefit in that I can present the dialog in the WebBrowser so that the operator
can watch the progress.

The popup for proxy authentication for the WebBrowser is acceptable, and will
work nicely. I will continue with this approach, it seems next I need to learn
how to POST back to a subframe. It's encouraging.

Thank you very much,
Mark

Peter Huang wrote:
Hi Mark,

Thanks for keeping me posted.
I understand how difficult these times are for you both, and I sincerely
hope that your wife continues to respond well to her treatment .

First I agree with that we can use the GlobalProxySelection when using
WebClient. WebClient class use WebRequest class to access the internet.
Therefore you can use GlobalProxySelection class to select a global proxy.
Then the proxy will also be used by WebClient. More information about the
proxy, please check the reference of Proxy property of HttpWebRequest class.

HttpWebRequest.Proxy Property
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemNetHttpWebRequestClassProxyTopic.asp

As for the Webbrowser control, its behavior is similar with the internet
explorer. When we access a website via an authentication proxy, it will
popup a dialog to input the credential. My suggestion is to save the html
file with frame to the local disk and then load it into the webbrowser from
local so that we do not need to handle the authentication in the WebBrowser.
If you feel the approach is somewhat tedious, I think you may try to parse
the html file returned back manually when you post the username password to
the login website. So that we do not need to use the WebBrowser control.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #14
Hi Mark,

I am glad that my suggestion will help you.
Also if you still have any question about the issue, please feel free to
post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #15
Peter,

I'm close to getting this to work. I actually got a boost from some examples
in VB6 I found on the net, helps to understand what the object does and what it
offers. I've learned how to set the internal visible and hidden variables.
The only thing left is to figure out how to fire the submit button without the
user actually clicking the button on the displayed webbrowser.

Again, thanks for all the help,
Mark

Peter Huang wrote:
Hi Mark,

I am glad that my suggestion will help you.
Also if you still have any question about the issue, please feel free to
post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #16
Hi Mark,

To simulate a form click, we can use the HTML DOM.

Here is the sample code, you may take a look.

Private Sub Command1_Click()
Dim htmldoc As HTMLDocument
Set htmldoc = Me.WebBrowser1.Document
Dim htmlFrm As HTMLFormElement
Set htmlFrm = htmldoc.Forms("f")
htmlFrm.Item("q").Value = "Test Search Engine"
htmlFrm.submit
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.google.com"
End Sub
But as I said before, if the form is in a frame, we may not access to the
form under the frame. So I think in this senario, you'd better use the
webclient to do the upload issues.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #17
Peter,

Thank you for the suggestion. I will see how far I can take this!
My wife came home from hospital Friday and is feeling well today.

thanks again,
Mark

Peter Huang wrote:
Hi Mark,

To simulate a form click, we can use the HTML DOM.

Here is the sample code, you may take a look.

Private Sub Command1_Click()
Dim htmldoc As HTMLDocument
Set htmldoc = Me.WebBrowser1.Document
Dim htmlFrm As HTMLFormElement
Set htmlFrm = htmldoc.Forms("f")
htmlFrm.Item("q").Value = "Test Search Engine"
htmlFrm.submit
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.google.com"
End Sub

But as I said before, if the form is in a frame, we may not access to the
form under the frame. So I think in this senario, you'd better use the
webclient to do the upload issues.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #18
Peter,

I have nearly completed what I set out to do...
The example you provided below is remarkably close to providing the final step
I need.

An alternate way to submit the form in the example you provided is as follows:

htmlFrm.Item("btnG").Click

The click event on the button results in the form being submitted.

In my application, instead of a button I have a table cell containing an image
and java code to execute on a click event that results in a submit operation.
<TD> <A onclick='if( [...] submitForm("Send") [...];' href=""> <IMG
src="/[...]" </A></TD>
Since the image is unnamed I am uncertain how to accomplish firing the click
event. Unfortunately a statement of the type htmlFrm.submit does not work
because the necessary java code is not executed. An alternate would be to
directly execute the java code, but is that possible?

Thank you for any suggestions,
Mark.

Peter Huang wrote:
Hi Mark,

To simulate a form click, we can use the HTML DOM.

Here is the sample code, you may take a look.

Private Sub Command1_Click()
Dim htmldoc As HTMLDocument
Set htmldoc = Me.WebBrowser1.Document
Dim htmlFrm As HTMLFormElement
Set htmlFrm = htmldoc.Forms("f")
htmlFrm.Item("q").Value = "Test Search Engine"
htmlFrm.submit
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.google.com"
End Sub

But as I said before, if the form is in a frame, we may not access to the
form under the frame. So I think in this senario, you'd better use the
webclient to do the upload issues.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #19
Hi Mark,

From my understanding, you will run a java applet in the img's click event,
am I right?
In client side, i.e. the Internet Explorer, we can run the java applet with
client script, e.g. java script. I think we can not run the java applet
directly, but we can run it in a script function, such as the button_click
event handler function. So I think we will need to put the routine that
will excute the java code in an event handler function, similar as what you
have did.
Since the image do not have a name, we can use the index to access the
item, such as htmlFrm.Item(1).Value.
Or
I think we can write another button_click or else and in the handle
function to run the java applet.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #20

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

Similar topics

2
by: EricP | last post by:
I'm trying to figure out how to print from IE 6.0 using Python's Win32all com library. When I do from win32com.client import Dispatch from time import sleep ie =...
7
by: Limey Drink | last post by:
Hi all, Firstly :-) , is there any where I can search through archived newsgroup posts so I am not cluttering up the newsgroup with repeated queries ? And secondly :-), I know this has...
7
by: xzzy | last post by:
I need to automate a report in a different database (and thank yous to Terry Kreft for pointing me in the right direction). below is the code with the one line that does not work, marked: 'Does...
2
by: Chris Potter | last post by:
I have a problem. I am constructing a database of eople's names and addresses for business purposes. This requires all of the people to be numbered eg: 1,2,3,4,5,6,7,8,9,10 But the problem lies...
6
by: pradeep_TP | last post by:
I am facing a strange problem with my web site. Afer reinstalling the web application on the web server, I am getting a dialog box for each page. The dialog box has the following information. ...
6
by: Mark Gross | last post by:
I am attempting to programatically drive a Lotus Notes web application from a VB.NET database application (who wants to rekey information in one database into someone else's web page for entry to...
0
by: Stephen | last post by:
First off sorry if this is not the right group but thought I would be close. I am experimenting with automating my development build processes. Want to to go opensource on this one so looking into...
1
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to...
2
by: nandishp | last post by:
We need to automate download of Reports from Oracle CRM OnDemand. The reports in Siebel CRM OnDemand can be downloaded in the form of Excel, CSV, etc. We have a task of downloading several such...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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: 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...

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.