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

ASPNET and Webbrowser control

Hello,
I Created a AxSHDocVw.AxWebBrowser in a class and want to Post Values
to a WebPage. When I use this class in a Windows application,
everything is fine, but in an ASPX page it hangs after the .submit
(see code)

Even if i try to start the class in a new thread it terminates at the
..submit

Any ideas?

-----------------
Imports mshtml

Public Class cEbay

'Inherits System.Windows.Forms.Form

Private m_iStatus As Integer
Private m_sUserID As String
Private m_sPassword As String
Private m_sReturnString As String
Private m_bTransactionFinished As Boolean
Private m_bPassString As String
Private m_bTimerFinished As Boolean

Const sURL_SignIn As String =
"http://cgi.ebay.de/aw-cgi/eBayISAPI.dll?SignIn"
Const sURL_UserData As String =
"http://cgi4.ebay.de/aw-cgi/eBayISAPI.dll?ChangeRegistrationShow&UsingSSL=0&co untryid=0&pass=[pass]&userid=[userid]"
Const sURL_LogOut =
"http://signin.ebay.de/aw-cgi/eBayISAPI.dll?SignIn&ssPageName=h:h:sout:DE"
Const sURL_MyEbay =
"http://cgi1.ebay.de/aw-cgi/eBayISAPI.dll?MfcISAPICommand=MyeBayItemsBiddingOn &userid=[userid]&pass=[pass]&dayssince=20"

Private iTimeoutSec As Integer = 15
Private components As System.ComponentModel.IContainer
Friend WithEvents WebBrowser1 As AxSHDocVw.AxWebBrowser

Public Sub New()
MyBase.New()
m_iStatus = 0
'WebBrowser1.Show()

Me.components = New System.ComponentModel.Container
Me.WebBrowser1 = New AxSHDocVw.AxWebBrowser
Me.WebBrowser1.Enabled = True
Dim resources As System.Resources.ResourceManager = New
System.Resources.ResourceManager(GetType(cEbay))
Me.WebBrowser1.OcxState =
CType(resources.GetObject("AxWebBrowser1.OcxState" ),
System.Windows.Forms.AxHost.State)
Dim frm As New System.Windows.Forms.Form
frm.Controls.Add(Me.WebBrowser1)
CType(Me.WebBrowser1,
System.ComponentModel.ISupportInitialize).EndInit( )

WebBrowser1.Navigate("about:blank")

End Sub

#Region "Properties"

'TimeOutSec
Public Property TimeOutSec() As Integer
Get
TimeOutSec = iTimeoutSec
End Get
Set(ByVal Value As Integer)
iTimeoutSec = Value
End Set
End Property

'UserID
Public Property EBAY_UserID() As String
Get
EBAY_UserID = m_sUserID
End Get
Set(ByVal Value As String)
m_sUserID = Value
End Set
End Property

'Password
Public Property EBAY_Password() As String
Get
EBAY_Password = m_sPassword
End Get
Set(ByVal Value As String)
m_sPassword = Value
End Set
End Property
'Address
Public Property EBAY_Address() As String
Get
EBAY_Address = m_sAddress
End Get
Set(ByVal Value As String)
m_sAddress = Value
End Set
End Property
#End Region
Private Sub WebBrowser1_DocumentComplete(ByVal sender As Object,
ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent ) Handles
WebBrowser1.DocumentComplete

'Print WebBrowser1.Document.body.innerhtml
Try
Select Case m_iStatus
'-------------------------------------------------------------GetEbayAddress
'-------------------------------------------------------------GetEbayAddress
'-------------------------------------------------------------GetEbayAddress
Case 10
WebBrowser1.Navigate(sURL_SignIn)
Case 11

WebBrowser1.Navigate(sURL_UserData)
Case 12
'Login
WebBrowser1.Document.Forms("SignInForm").UserID.va lue
= m_sUserID
WebBrowser1.Document.Forms("SignInForm").pass.valu e
= m_sPassword
WebBrowser1.Document.Forms("SignInForm").submit()
<<<------Here
it freezes, but not in a Window Application! What can I do??? Any
Suggestions?

'For Each frm As mshtml.HTMLFormElementClass In
WebBrowser1.Document.Forms
' If frm.Name = "SignInForm" Then

' frm.elements.UserID.Value = m_sUserID
' frm.elements.pass.Value = m_sPassword
' frm.elements.keepMeSignInOption.Value = 1
' frm.setActive()
' frm.Submit()

' End If
'Next

Case 13

End Select

m_iStatus += 1
Catch ex As Exception
End Try

End Sub

Function GetEbayAddress() As String
Try
m_iStatus = 10
m_sAddress = ""
m_bBidFailed = True
m_bTransactionFinished = False
m_sAddress = ""
WebBrowser1.Navigate(sURL_LogOut)

Dim myTimer As System.Timers.Timer
myTimer = New System.Timers.Timer
myTimer.AutoReset = True
myTimer.Interval = iTimeoutSec * 1000
AddHandler myTimer.Elapsed, New
System.Timers.ElapsedEventHandler(AddressOf ElapsedEventHandler)
m_bTimerFinished = False
myTimer.Start()

Do
If m_bTimerFinished Or m_bTransactionFinished Then
Exit Do
System.Windows.Forms.Application.DoEvents()
Loop

GetEbayAddress = m_sAddress

Catch ex As Exception
End Try
End Function

Sub ElapsedEventHandler(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs)
m_bTimerFinished = True
End Sub
'----------------- The Starter
Public Function GetAddress(ByVal sPassword As String, ByVal
sUserID As String) As String
Dim sResult As String

Dim oEbayThread As New Thread(AddressOf thread_GetEbayAddress)
oEbayThread.IsBackground = False
oEbayThread.ApartmentState = Threading.ApartmentState.STA
oEbayThread.Start()
oEbayThread.Join()

GetEbayAddress = m_sEbayAddress
End Function

Private Sub thread_GetEbayAddress()
Dim ebay As New cEbay
ebay.EBAY_Password = "password"
ebay.EBAY_UserID = "user"
m_sEbayAddress = ebay.GetEbayAddress()
End Sub
Nov 18 '05 #1
1 3678
Hi Daniel,

In ASP.NET, I think you'd be much better of with the Webclient class to do
this kind of thing:

Provides common methods for sending data to and receiving data from a
resource identified by a URI.

http://msdn.microsoft.com/library/de...ClassTopic.asp
HOWTO: Use WebClient Class To Make HTTP Requests

http://support.microsoft.com/default...b;en-us;328820

Ken
Microsoft MVP [ASP.NET]
"Daniel Frede" <fr***@ibis-thome.de> wrote in message
news:4d**************************@posting.google.c om...
Hello,
I Created a AxSHDocVw.AxWebBrowser in a class and want to Post Values
to a WebPage. When I use this class in a Windows application,
everything is fine, but in an ASPX page it hangs after the .submit
(see code)

Even if i try to start the class in a new thread it terminates at the
.submit

Any ideas?

-----------------
Imports mshtml

Public Class cEbay

'Inherits System.Windows.Forms.Form

Private m_iStatus As Integer
Private m_sUserID As String
Private m_sPassword As String
Private m_sReturnString As String
Private m_bTransactionFinished As Boolean
Private m_bPassString As String
Private m_bTimerFinished As Boolean

Const sURL_SignIn As String =
"http://cgi.ebay.de/aw-cgi/eBayISAPI.dll?SignIn"
Const sURL_UserData As String =
"http://cgi4.ebay.de/aw-cgi/eBayISAPI.dll?ChangeRegistrationShow&UsingSSL=0&co untryid=0&pass=[pass]&userid=[userid]"
Const sURL_LogOut =
"http://signin.ebay.de/aw-cgi/eBayISAPI.dll?SignIn&ssPageName=h:h:sout:DE"
Const sURL_MyEbay =
"http://cgi1.ebay.de/aw-cgi/eBayISAPI.dll?MfcISAPICommand=MyeBayItemsBiddingOn &userid=[userid]&pass=[pass]&dayssince=20"

Private iTimeoutSec As Integer = 15
Private components As System.ComponentModel.IContainer
Friend WithEvents WebBrowser1 As AxSHDocVw.AxWebBrowser

Public Sub New()
MyBase.New()
m_iStatus = 0
'WebBrowser1.Show()

Me.components = New System.ComponentModel.Container
Me.WebBrowser1 = New AxSHDocVw.AxWebBrowser
Me.WebBrowser1.Enabled = True
Dim resources As System.Resources.ResourceManager = New
System.Resources.ResourceManager(GetType(cEbay))
Me.WebBrowser1.OcxState =
CType(resources.GetObject("AxWebBrowser1.OcxState" ),
System.Windows.Forms.AxHost.State)
Dim frm As New System.Windows.Forms.Form
frm.Controls.Add(Me.WebBrowser1)
CType(Me.WebBrowser1,
System.ComponentModel.ISupportInitialize).EndInit( )

WebBrowser1.Navigate("about:blank")

End Sub

#Region "Properties"

'TimeOutSec
Public Property TimeOutSec() As Integer
Get
TimeOutSec = iTimeoutSec
End Get
Set(ByVal Value As Integer)
iTimeoutSec = Value
End Set
End Property

'UserID
Public Property EBAY_UserID() As String
Get
EBAY_UserID = m_sUserID
End Get
Set(ByVal Value As String)
m_sUserID = Value
End Set
End Property

'Password
Public Property EBAY_Password() As String
Get
EBAY_Password = m_sPassword
End Get
Set(ByVal Value As String)
m_sPassword = Value
End Set
End Property
'Address
Public Property EBAY_Address() As String
Get
EBAY_Address = m_sAddress
End Get
Set(ByVal Value As String)
m_sAddress = Value
End Set
End Property
#End Region
Private Sub WebBrowser1_DocumentComplete(ByVal sender As Object,
ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent ) Handles
WebBrowser1.DocumentComplete

'Print WebBrowser1.Document.body.innerhtml
Try
Select Case m_iStatus

'-------------------------------------------------------------GetEbayAddress

'-------------------------------------------------------------GetEbayAddress

'-------------------------------------------------------------GetEbayAddress
Case 10
WebBrowser1.Navigate(sURL_SignIn)
Case 11

WebBrowser1.Navigate(sURL_UserData)
Case 12
'Login
WebBrowser1.Document.Forms("SignInForm").UserID.va lue
= m_sUserID
WebBrowser1.Document.Forms("SignInForm").pass.valu e
= m_sPassword
WebBrowser1.Document.Forms("SignInForm").submit()
<<<------Here
it freezes, but not in a Window Application! What can I do??? Any
Suggestions?

'For Each frm As mshtml.HTMLFormElementClass In
WebBrowser1.Document.Forms
' If frm.Name = "SignInForm" Then

' frm.elements.UserID.Value = m_sUserID
' frm.elements.pass.Value = m_sPassword
' frm.elements.keepMeSignInOption.Value = 1
' frm.setActive()
' frm.Submit()

' End If
'Next

Case 13

End Select

m_iStatus += 1
Catch ex As Exception
End Try

End Sub

Function GetEbayAddress() As String
Try
m_iStatus = 10
m_sAddress = ""
m_bBidFailed = True
m_bTransactionFinished = False
m_sAddress = ""
WebBrowser1.Navigate(sURL_LogOut)

Dim myTimer As System.Timers.Timer
myTimer = New System.Timers.Timer
myTimer.AutoReset = True
myTimer.Interval = iTimeoutSec * 1000
AddHandler myTimer.Elapsed, New
System.Timers.ElapsedEventHandler(AddressOf ElapsedEventHandler)
m_bTimerFinished = False
myTimer.Start()

Do
If m_bTimerFinished Or m_bTransactionFinished Then
Exit Do
System.Windows.Forms.Application.DoEvents()
Loop

GetEbayAddress = m_sAddress

Catch ex As Exception
End Try
End Function

Sub ElapsedEventHandler(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs)
m_bTimerFinished = True
End Sub
'----------------- The Starter
Public Function GetAddress(ByVal sPassword As String, ByVal
sUserID As String) As String
Dim sResult As String

Dim oEbayThread As New Thread(AddressOf thread_GetEbayAddress)
oEbayThread.IsBackground = False
oEbayThread.ApartmentState = Threading.ApartmentState.STA
oEbayThread.Start()
oEbayThread.Join()

GetEbayAddress = m_sEbayAddress
End Function

Private Sub thread_GetEbayAddress()
Dim ebay As New cEbay
ebay.EBAY_Password = "password"
ebay.EBAY_UserID = "user"
m_sEbayAddress = ebay.GetEbayAddress()
End Sub


Nov 18 '05 #2

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

Similar topics

5
by: Noozer | last post by:
I've got a WebBrowser control (AxBrowse - VCMAXB.DLL) and I'm having a few difficulties with it. Just looking for a few pointers, not whole solutions here. I've tried looking at the MSDN help files...
4
by: Randy | last post by:
Hi, ok, I found a way to connect to a running instance of an (external) Internet Explorer and access - for example - the html source. That works fine! But now I have running application with...
9
by: ASP .NET Newbie | last post by:
How can I run a WebBrowser control using ASP.NET/VB.NET? I know I can use the WebClient to get the page data, but I need to be able to use the WebBrowser (AxWebBrowser)? Thanks, Chad
1
by: Tuong | last post by:
I have a situation where i have a form that contains a webbrowser control. With this I was able to implement an application that can browse websites. One particular website i visited opens up...
0
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads,...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
8
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : ...
11
by: Anil Gupte | last post by:
....and how do I insert one into my form? I used in VB 6.0 last, but cannot figure out where it is in .Net Thanx, -- Anil Gupte www.keeninc.net www.icinema.com
4
by: Steve Richter | last post by:
I would like to build an HTML stream as a string and have the WebBrowser control render that HTML. Then on PostBack, or whatever it is called, I would like my code to be the one that receives what...
5
by: kimiraikkonen | last post by:
Hi, I couldn't find a necessary class which shows when mouse hovers on a link in Webbrowser control. Think of there's a status bar(text), when mouse comes on a link, the URL must be shown in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.