473,320 Members | 2,107 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,320 software developers and data experts.

WebBrowser - changing HTML content after DocumentCompleted event

Folks,

I am facing a problem. I am trying to manipulate the HTML data (thru the
Document and DocumentText properties) of the WebBrowser object
(System.Windows.Forms).

The problem is that the application enters in a loop state and my changes
don't apply.

Have somebody faced the same problem? Any solutions?

I am using C# / .Net 2.0.

--
Regards,
Robson Siqueira
Enterprise Architect
Mar 30 '07 #1
4 13307
Hi.

I've done a lot of code that resuses the IE control. I'm not sure what you
mean by "the application enters in a loop state", though. You mean your code
goes into a tight loop and the app freezes or what? If so, don't do that...
:-)

Can you give me an example of exactly what you're trying to change/do?
Perhaps something I can recreate on my end/write a quick piece of code as an
example for you?

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:u3**************@TK2MSFTNGP06.phx.gbl...
Folks,

I am facing a problem. I am trying to manipulate the HTML data (thru the
Document and DocumentText properties) of the WebBrowser object
(System.Windows.Forms).

The problem is that the application enters in a loop state and my changes
don't apply.

Have somebody faced the same problem? Any solutions?

I am using C# / .Net 2.0.

--
Regards,
Robson Siqueira
Enterprise Architect

Mar 30 '07 #2
Actually I want to change the code after it is loaded, which happens after
the DocumentCompleted Event. The problem is that the application keeps
loading the file - if you change it goes all the way over again - and so on.

Do you have any example in which you manipulate the HTML code AFTER the
document was loaded?

Thanks!

--
Regards,
Robson Siqueira
Enterprise Architect
"Ben Rush" <kw*****@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi.

I've done a lot of code that resuses the IE control. I'm not sure what you
mean by "the application enters in a loop state", though. You mean your
code goes into a tight loop and the app freezes or what? If so, don't do
that... :-)

Can you give me an example of exactly what you're trying to change/do?
Perhaps something I can recreate on my end/write a quick piece of code as
an example for you?

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:u3**************@TK2MSFTNGP06.phx.gbl...
>Folks,

I am facing a problem. I am trying to manipulate the HTML data (thru the
Document and DocumentText properties) of the WebBrowser object
(System.Windows.Forms).

The problem is that the application enters in a loop state and my changes
don't apply.

Have somebody faced the same problem? Any solutions?

I am using C# / .Net 2.0.

--
Regards,
Robson Siqueira
Enterprise Architect


Mar 30 '07 #3
Sounds like you might be having the same problem I had.

Click on this:
news://msnews.microsoft.com/ee******...TNGP02.phx.gbl

If your problem is similar to mine, then to get the DocumentComplete when it
loads, reference shdocvw (find the COM object DLL in
C:\Windows\System32\shdocvw.dll and reference it in your .NET app) and cast
your ((System.Windows.Forms.WebBrowser)webBrowser1).Act iveXObject to a
SHDocVw.WebBrowser variable. Then subscribe to the DocumentComplete event of
the COM object, rather than the DocumentComplete event of the Windows Forms
instance.

shdocvw.WebBrowser _ActiveXBrowser = null;
public shdocvw.WebBrowser ActiveXBrowser
{
get
{
if (_ActiveXBrowser == null)
{
_ActiveXBrowser =
(SHDocVw.WebBrowser)myWebBrowser.ActiveXInstance;
}
return _ActiveXBrowser;
}
}

private void InitBrowser()
{
_ActiveXBrowser.DocumentComplete += new
SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHa ndler(ActiveXBrowser_DocumentComplete);
}
To avoid the re-load loop after changing the document content, set a flag in
your event handler to ignore the event if you just changed something.

Jon
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:el**************@TK2MSFTNGP03.phx.gbl...
Actually I want to change the code after it is loaded, which happens after
the DocumentCompleted Event. The problem is that the application keeps
loading the file - if you change it goes all the way over again - and so
on.

Do you have any example in which you manipulate the HTML code AFTER the
document was loaded?

Thanks!

--
Regards,
Robson Siqueira
Enterprise Architect
"Ben Rush" <kw*****@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi.

I've done a lot of code that resuses the IE control. I'm not sure what
you mean by "the application enters in a loop state", though. You mean
your code goes into a tight loop and the app freezes or what? If so,
don't do that... :-)

Can you give me an example of exactly what you're trying to change/do?
Perhaps something I can recreate on my end/write a quick piece of code as
an example for you?

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:u3**************@TK2MSFTNGP06.phx.gbl...
>>Folks,

I am facing a problem. I am trying to manipulate the HTML data (thru the
Document and DocumentText properties) of the WebBrowser object
(System.Windows.Forms).

The problem is that the application enters in a loop state and my
changes don't apply.

Have somebody faced the same problem? Any solutions?

I am using C# / .Net 2.0.

--
Regards,
Robson Siqueira
Enterprise Architect



Mar 30 '07 #4
Also if you're dynamicizing the content, try to use the IE-DHTML DOM first,
i.e. myBrowser.Document.Body.InnerHtml = ..., rather than
myBrowser.DocumentText = .... Or, use
((mshtml.HTMLDocument)myBrowser.Document.DomDocume nt).body.innerHTML=...
(with mshtml.dll referenced).

Jon
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:el**************@TK2MSFTNGP03.phx.gbl...
Actually I want to change the code after it is loaded, which happens after
the DocumentCompleted Event. The problem is that the application keeps
loading the file - if you change it goes all the way over again - and so
on.

Do you have any example in which you manipulate the HTML code AFTER the
document was loaded?

Thanks!

--
Regards,
Robson Siqueira
Enterprise Architect
"Ben Rush" <kw*****@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi.

I've done a lot of code that resuses the IE control. I'm not sure what
you mean by "the application enters in a loop state", though. You mean
your code goes into a tight loop and the app freezes or what? If so,
don't do that... :-)

Can you give me an example of exactly what you're trying to change/do?
Perhaps something I can recreate on my end/write a quick piece of code as
an example for you?

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:u3**************@TK2MSFTNGP06.phx.gbl...
>>Folks,

I am facing a problem. I am trying to manipulate the HTML data (thru the
Document and DocumentText properties) of the WebBrowser object
(System.Windows.Forms).

The problem is that the application enters in a loop state and my
changes don't apply.

Have somebody faced the same problem? Any solutions?

I am using C# / .Net 2.0.

--
Regards,
Robson Siqueira
Enterprise Architect



Mar 31 '07 #5

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

Similar topics

3
by: mvargasp | last post by:
Hi all, I have a web form which contains a frame, (a form containing a menu on the left and a web form containing a datagrid on the right). Also there is a button (right side) which transforms...
2
by: bill | last post by:
Hi All, When I send html content with Excel MIME type, the page break style sheet {page-break-before: always} doesn't work at Excel spreadsheet. Any idea to convert html page break style sheet to...
2
by: rpesq | last post by:
Hi, I Need help changing the content of a DIV. I sincerely researched the issue and have not found a solution except to scrap the idea and stick with the iframe code that I had been using. My...
2
by: Don Tucker | last post by:
Sorry, I attempted to tab in the previous post and accidentally posted prematurely. I am trying to use the WebBrowser control from Visual Studio 2005 to load a web page and display its HTML...
4
by: eewwttww | last post by:
how to save with only WebBrowser: save html+picture without dialog box? what I Have is: WebBrowser.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER, 300, 300 I don't want this code. I want...
3
by: Sam | last post by:
Hi All, Is it possible to get a web page content of one of my webpages using relative path? for example: If I have a website which consists of 2 pages: testpage1.aspx and testpage2.aspx...
1
by: Jeremy | last post by:
Hi, I am attempting to load an ad Banner to coincide with a piece of video pre-roll. The following function is called which is supposed to create an empty IFRAME. Once this IFRAME object is...
1
by: marymak | last post by:
Hi everyone, I am looking for a script that will allow me to have the HTML content of a div tag (text and graphics) change when a page is refreshed. I would also like it to randomly choose between...
0
by: arindams | last post by:
I've a form where an webrowser contains a html file. I want to copy a selective portion of the html content and paste that content in an excel 2007 file where it will be pasted as a normal text (not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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

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