473,795 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASPNET and Webbrowser control

Hello,
I Created a AxSHDocVw.AxWeb Browser 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_bTransactionF inished As Boolean
Private m_bPassString As String
Private m_bTimerFinishe d As Boolean

Const sURL_SignIn As String =
"http://cgi.ebay.de/aw-cgi/eBayISAPI.dll?S ignIn"
Const sURL_UserData As String =
"http://cgi4.ebay.de/aw-cgi/eBayISAPI.dll?C hangeRegistrati onShow&UsingSSL =0&countryid=0& pass=[pass]&userid=[userid]"
Const sURL_LogOut =
"http://signin.ebay.de/aw-cgi/eBayISAPI.dll?S ignIn&ssPageNam e=h:h:sout:DE"
Const sURL_MyEbay =
"http://cgi1.ebay.de/aw-cgi/eBayISAPI.dll?M fcISAPICommand= MyeBayItemsBidd ingOn&userid=[userid]&pass=[pass]&dayssince=2 0"

Private iTimeoutSec As Integer = 15
Private components As System.Componen tModel.IContain er
Friend WithEvents WebBrowser1 As AxSHDocVw.AxWeb Browser

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

Me.components = New System.Componen tModel.Containe r
Me.WebBrowser1 = New AxSHDocVw.AxWeb Browser
Me.WebBrowser1. Enabled = True
Dim resources As System.Resource s.ResourceManag er = New
System.Resource s.ResourceManag er(GetType(cEba y))
Me.WebBrowser1. OcxState =
CType(resources .GetObject("AxW ebBrowser1.OcxS tate"),
System.Windows. Forms.AxHost.St ate)
Dim frm As New System.Windows. Forms.Form
frm.Controls.Ad d(Me.WebBrowser 1)
CType(Me.WebBro wser1,
System.Componen tModel.ISupport Initialize).End Init()

WebBrowser1.Nav igate("about:bl ank")

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_Doc umentComplete(B yVal sender As Object,
ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event) Handles
WebBrowser1.Doc umentComplete

'Print WebBrowser1.Doc ument.body.inne rhtml
Try
Select Case m_iStatus
'-------------------------------------------------------------GetEbayAddress
'-------------------------------------------------------------GetEbayAddress
'-------------------------------------------------------------GetEbayAddress
Case 10
WebBrowser1.Nav igate(sURL_Sign In)
Case 11

WebBrowser1.Nav igate(sURL_User Data)
Case 12
'Login
WebBrowser1.Doc ument.Forms("Si gnInForm").User ID.value
= m_sUserID
WebBrowser1.Doc ument.Forms("Si gnInForm").pass .value
= m_sPassword
WebBrowser1.Doc ument.Forms("Si gnInForm").subm it()
<<<------Here
it freezes, but not in a Window Application! What can I do??? Any
Suggestions?

'For Each frm As mshtml.HTMLForm ElementClass In
WebBrowser1.Doc ument.Forms
' If frm.Name = "SignInForm " Then

' frm.elements.Us erID.Value = m_sUserID
' frm.elements.pa ss.Value = m_sPassword
' frm.elements.ke epMeSignInOptio n.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_bTransactionF inished = False
m_sAddress = ""
WebBrowser1.Nav igate(sURL_LogO ut)

Dim myTimer As System.Timers.T imer
myTimer = New System.Timers.T imer
myTimer.AutoRes et = True
myTimer.Interva l = iTimeoutSec * 1000
AddHandler myTimer.Elapsed , New
System.Timers.E lapsedEventHand ler(AddressOf ElapsedEventHan dler)
m_bTimerFinishe d = False
myTimer.Start()

Do
If m_bTimerFinishe d Or m_bTransactionF inished Then
Exit Do
System.Windows. Forms.Applicati on.DoEvents()
Loop

GetEbayAddress = m_sAddress

Catch ex As Exception
End Try
End Function

Sub ElapsedEventHan dler(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs )
m_bTimerFinishe d = True
End Sub
'----------------- The Starter
Public Function GetAddress(ByVa l sPassword As String, ByVal
sUserID As String) As String
Dim sResult As String

Dim oEbayThread As New Thread(AddressO f thread_GetEbayA ddress)
oEbayThread.IsB ackground = False
oEbayThread.Apa rtmentState = Threading.Apart mentState.STA
oEbayThread.Sta rt()
oEbayThread.Joi n()

GetEbayAddress = m_sEbayAddress
End Function

Private Sub thread_GetEbayA ddress()
Dim ebay As New cEbay
ebay.EBAY_Passw ord = "password"
ebay.EBAY_UserI D = "user"
m_sEbayAddress = ebay.GetEbayAdd ress()
End Sub
Nov 18 '05 #1
1 3696
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.goo gle.com...
Hello,
I Created a AxSHDocVw.AxWeb Browser 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_bTransactionF inished As Boolean
Private m_bPassString As String
Private m_bTimerFinishe d As Boolean

Const sURL_SignIn As String =
"http://cgi.ebay.de/aw-cgi/eBayISAPI.dll?S ignIn"
Const sURL_UserData As String =
"http://cgi4.ebay.de/aw-cgi/eBayISAPI.dll?C hangeRegistrati onShow&UsingSSL =0&countryid=0& pass=[pass]&userid=[userid]"
Const sURL_LogOut =
"http://signin.ebay.de/aw-cgi/eBayISAPI.dll?S ignIn&ssPageNam e=h:h:sout:DE"
Const sURL_MyEbay =
"http://cgi1.ebay.de/aw-cgi/eBayISAPI.dll?M fcISAPICommand= MyeBayItemsBidd ingOn&userid=[userid]&pass=[pass]&dayssince=2 0"

Private iTimeoutSec As Integer = 15
Private components As System.Componen tModel.IContain er
Friend WithEvents WebBrowser1 As AxSHDocVw.AxWeb Browser

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

Me.components = New System.Componen tModel.Containe r
Me.WebBrowser1 = New AxSHDocVw.AxWeb Browser
Me.WebBrowser1. Enabled = True
Dim resources As System.Resource s.ResourceManag er = New
System.Resource s.ResourceManag er(GetType(cEba y))
Me.WebBrowser1. OcxState =
CType(resources .GetObject("AxW ebBrowser1.OcxS tate"),
System.Windows. Forms.AxHost.St ate)
Dim frm As New System.Windows. Forms.Form
frm.Controls.Ad d(Me.WebBrowser 1)
CType(Me.WebBro wser1,
System.Componen tModel.ISupport Initialize).End Init()

WebBrowser1.Nav igate("about:bl ank")

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_Doc umentComplete(B yVal sender As Object,
ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event) Handles
WebBrowser1.Doc umentComplete

'Print WebBrowser1.Doc ument.body.inne rhtml
Try
Select Case m_iStatus

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

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

'-------------------------------------------------------------GetEbayAddress
Case 10
WebBrowser1.Nav igate(sURL_Sign In)
Case 11

WebBrowser1.Nav igate(sURL_User Data)
Case 12
'Login
WebBrowser1.Doc ument.Forms("Si gnInForm").User ID.value
= m_sUserID
WebBrowser1.Doc ument.Forms("Si gnInForm").pass .value
= m_sPassword
WebBrowser1.Doc ument.Forms("Si gnInForm").subm it()
<<<------Here
it freezes, but not in a Window Application! What can I do??? Any
Suggestions?

'For Each frm As mshtml.HTMLForm ElementClass In
WebBrowser1.Doc ument.Forms
' If frm.Name = "SignInForm " Then

' frm.elements.Us erID.Value = m_sUserID
' frm.elements.pa ss.Value = m_sPassword
' frm.elements.ke epMeSignInOptio n.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_bTransactionF inished = False
m_sAddress = ""
WebBrowser1.Nav igate(sURL_LogO ut)

Dim myTimer As System.Timers.T imer
myTimer = New System.Timers.T imer
myTimer.AutoRes et = True
myTimer.Interva l = iTimeoutSec * 1000
AddHandler myTimer.Elapsed , New
System.Timers.E lapsedEventHand ler(AddressOf ElapsedEventHan dler)
m_bTimerFinishe d = False
myTimer.Start()

Do
If m_bTimerFinishe d Or m_bTransactionF inished Then
Exit Do
System.Windows. Forms.Applicati on.DoEvents()
Loop

GetEbayAddress = m_sAddress

Catch ex As Exception
End Try
End Function

Sub ElapsedEventHan dler(ByVal sender As Object, ByVal e As
System.Timers.E lapsedEventArgs )
m_bTimerFinishe d = True
End Sub
'----------------- The Starter
Public Function GetAddress(ByVa l sPassword As String, ByVal
sUserID As String) As String
Dim sResult As String

Dim oEbayThread As New Thread(AddressO f thread_GetEbayA ddress)
oEbayThread.IsB ackground = False
oEbayThread.Apa rtmentState = Threading.Apart mentState.STA
oEbayThread.Sta rt()
oEbayThread.Joi n()

GetEbayAddress = m_sEbayAddress
End Function

Private Sub thread_GetEbayA ddress()
Dim ebay As New cEbay
ebay.EBAY_Passw ord = "password"
ebay.EBAY_UserI D = "user"
m_sEbayAddress = ebay.GetEbayAdd ress()
End Sub


Nov 18 '05 #2

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

Similar topics

5
7555
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 with little success. - When a new window is trying to pop up, how do I determine the target URL? How can I get the page to open in the current browser control? - When printing from the webbrowser control is there a way to ensure it prints...
4
2888
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 an embedded IE webBrowser Control. Is there a possibility for my application to access the webBrowser control in the other application, too? Thanks in advance, Randy
9
3812
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
5586
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 another web page in a new window and then closes it. I was able to control this action by detecting the 'NewWindow' event and opening the webpage in my own application. Now the problem i have come across is that when the webpage that was opened in...
0
3480
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, displays, and executes. To gain this control, you need to implement your host's IDispatch so it handles DISPID_AMBIENT_DLCONTROL. When the WebBrowser Control is instantiated, it will call your IDispatch::Invoke with this ID. Set pvarResult to a...
12
6380
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 of course it's thrown up a whole host of new issues... I'm generating a multi page printable document in HTML from my app, and displaying it in a WebBrowser control. I've looked into using some CSS
8
3421
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
2845
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
12012
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 the WebBrowser control is sending. Effectively, my code would be the web server and the WebBrowser control would be the web client. All the examples I am seeing have the WebBrowser control being directed to a URL from which to get the HTML...
5
8079
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 this status bar. How can i do this? Thanks.
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.