Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

C# and AxWebBrowser

Posted on 2004-11-10
4
Medium Priority
?
1,010 Views
Last Modified: 2008-01-09
Hello,

I am using AxWebBrowser to access web pages from within my application.  I have two problems facing me off at the moment.

1.  Is there a method to intercept a 404 response prior to redirection (if any)?
2.  If the URL specified to the AxWebBrowser includes a filedownload of any description, how do I intercept this? (I don't want to enable this!)

Is it me, or is there not a great deal of documentation on the AxWebBrowser?!

I'd appreciate any help that can be offered.

Thanks
0
Comment
Question by:Si-clone
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
buraksarica earned 1500 total points
ID: 12548658
1st answer : use NavigateError event of axWebBrowser as shown below. (i assume that there is a label on the form named label1)

private void axWebBrowser1_NavigateError(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateErrorEvent e)
{
      if ((int)e.statusCode == 404)
      {
            label1.Text="not found";                        
      }
}

2nd answer : Try to use FileDownload of Web Browser control. There is an event argument class named e. This class has a property named cancel. Set cancel property to true. (Not tested)

Hope this helps.
Burak SARICA
0
 

Author Comment

by:Si-clone
ID: 12556972
Thanks for your reply.

I had previously tried the FileDownload event, but it didn't seem to fire.  However, on closer examination it appears that what I need to trap was a Java window offering to download a CAB file.  Maybe this is why the FileDownload event did not fire?!

One further question if I may :-)

Do you know the difference between events such as NewWindow2 and NewWindow3?

Thanks for your help.



0
 
LVL 5

Expert Comment

by:buraksarica
ID: 12559794
NewWindow is an event on older versions of internet explorer that raises when a new window is to be created. NewWindow2 is the newer version of this event. It uses the same arguments but it works better. Because of this MSDN says "NewWindow is obsolete, use NewWindow2 instead". The NewWindow3 extends the event NewWindow2 and it supplies you with more information about the newly created window such as URL of the page opening the new window and URL being opened etc.

Hope this helps.
Burak SARICA
0
 

Author Comment

by:Si-clone
ID: 12571431
Thanks for your help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question