Rectangle 27 13

You should handle the WebBrowser.DocumentComplete event, once that event is raised you will have the Document etc.

wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
  WebBrowser wb = sender as WebBrowser;
  // wb.Document is not null at this point
}

Here is a complete example, that I quickly did in a Windows Forms application and tested.

public partial class Form1 : Form
  {
    public Form1()
    {      
      InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      WebBrowser wb = new WebBrowser();
      wb.AllowNavigation = true;

      wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);

      wb.Navigate("http://www.google.com");

              }

    private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
      WebBrowser wb = sender as WebBrowser;
      // wb.Document is not null at this point
    }
  }

Edit: Here is a simple version of code that runs a window from a console application. You can of course go further and expose the events to the console code etc.

using System;
using System.Windows;
using System.Windows.Forms;

namespace ConsoleApplication1
{
  class Program
  {    
    [STAThread] 
    static void Main(string[] args)
    {      
      Application.Run(new BrowserWindow());   

      Console.ReadKey();
    }
  }

  class BrowserWindow : Form
  {
    public BrowserWindow()
    {
      ShowInTaskbar = false;
      WindowState = FormWindowState.Minimized;
      Load += new EventHandler(Window_Load);
    }

    void Window_Load(object sender, EventArgs e)
    {      
      WebBrowser wb = new WebBrowser();
      wb.AllowNavigation = true;
      wb.DocumentCompleted += wb_DocumentCompleted;
      wb.Navigate("http://www.bing.com");      
    }

    void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
      Console.WriteLine("We have Bing");
    }
  }
}

This unfortunately does not work. The web browser never seems to even as so much as attempt loading the page. Adding in this code to my original snippet results in the DocumentCompleted event never being called and the program exiting.

@Dave, that is strange. I attached a complete piece of code that I quickly tested to confirm it works.

@Chris, I think the significant difference is I'm not creating or using the WebBrowser within a Form or class. Instead, I'm creating/using the WebBrowser from a library-like context (no UI) without intending to ever visually display the output. The goal was to simply get the HTML produced from requesting that page, after it has been processed by the client-side JavaScript embedded in that page.

@Dave, the problem there is that console applications do not have a message pump to process messages.

@Dave, I added a simplistic sample of how you could handle this from a console app.

.NET C#: WebBrowser control Navigate() does not load targeted URL - St...

c# .net controls browser navigateurl
Rectangle 27 1

I had this problem, and I did not realize that I had uninstalled Internet Explorer. If you have, nothing will ever happen, since the WebBrowser control only instantiates IE.

Actually, it's the other way around -- IE instantiates the same engine as the WebBrowser control :)

.NET C#: WebBrowser control Navigate() does not load targeted URL - St...

c# .net controls browser navigateurl
Rectangle 27 3

You probably need to host the control in a parent window. You can do this without breaking requirements by simply not showing the window that hosts the browser control by moving it off screen. It might also be useful for development to "see" that it does actually load something for testing, verification etc.

// in a form's Load handler:

WebBrowser wb = new WebBrowser();
this.Controls.Add(wb);
wb.AllowNavigation = true;
wb.Navigate("http://www.google.com/");

Also check to see what other properties are set on the WebBrowser object when you instantiate it via the IDE. E.g. create a Form, drop a browser control onto it and then check the form's designer file to see what code is generated. You might be missing some key property that needs to be set. I've discovered many-an-omission in my code in this way and also learned how to properly instantiate visual objects programmatically.

P.S. If you do use a host window, it should only be visible during development. You would hide in some manner for production.

System.Net.WebClient wc = new System.Net.WebClient();

  System.IO.StreamReader webReader = new System.IO.StreamReader(
         wc.OpenRead("http://your_website.com"));

  string webPageData = webReader.ReadToEnd();

...then RegEx or parse webPageData for what you need. Or do you need the jscript in the page to actually execute? (Which should be possible with .NET 4.0)

It's important to note that I'm also running this application under a [STAThread] (the entry of this program has this directive). Otherwise, an exception regarding ActiveX and STAThreads only supported is thrown. In the same function where I created the WebBrowser, I also tried creating a form and placing the WebBrowser control in that form. Like: WebBrowser wb = new WebBrowser(); Form f = new Form(); f.Controls.Add(wb); Leaving it at that then trying to Navigate does nothing. Showing the window then trying to Navigate does nothing.

The intended loads for this application dictates a need to avoid Forms and Windows: given that it needs to run 1000+ tests a day using this WebBrowser (if its practical), it'd be impractical to have someone sit and watch each page load.

@Paul, In response to your "Another approach" section, a raw format would be ok, however I -do- need the jscript on the page to execute. There is a particular interest in whether the jscript embedded in the pages being tested by this application appropriately modify the document.

.NET C#: WebBrowser control Navigate() does not load targeted URL - St...

c# .net controls browser navigateurl
Rectangle 27 2

FEATURE_BROWSER_EMULATION

If you have access to the web pages you're loading into WebBrowser, use X-UA-Compatible:

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    ...
</head>

You can also try IE=EmulateIE8, the difference is explained here.

  • Once the above has been done, verify the actual document mode: webBrowser.DocumentCompleted += (s, e) => MessageBox.Show( ((dynamic)webBrowser.Document.DomDocument).documentMode.ToString());

c# - how to make winforms webbrowser control to work very similar to t...

c# .net winforms webbrowser-control
Rectangle 27 2

FEATURE_BROWSER_EMULATION

If you have access to the web pages you're loading into WebBrowser, use X-UA-Compatible:

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    ...
</head>

You can also try IE=EmulateIE8, the difference is explained here.

  • Once the above has been done, verify the actual document mode: webBrowser.DocumentCompleted += (s, e) => MessageBox.Show( ((dynamic)webBrowser.Document.DomDocument).documentMode.ToString());

c# - how to make winforms webbrowser control to work very similar to t...

c# .net winforms webbrowser-control
Rectangle 27 0

So would I use panels in some way? Some type of modified tab control?

You can use tab control in other way. Just hide the XtraTabControl headers via the XtraTabControl.ShowTabHeaders option.

DevExpress also recommended using the tab control, and just hiding the tabs. Seems a little sneaky, but i'll buy it! Scott Whylie also provided a good answer, however a bit more complicated than I need.

c# - WinForm with DevExpress NavBar Control and How to Change the Targ...

c# winforms devexpress
Rectangle 27 0

The Webbrowser control is just a wrapper around Internet Explorer.

You can set in onto an invisible Windows Forms window to completely instantiate it.

.NET C#: WebBrowser control Navigate() does not load targeted URL - St...

c# .net control browser navigateurl
Rectangle 27 0

Word has what are called Stories in the StoryRange collection - most routines run on the main body of the document itself of the wdMainTextStory type of WdStoryType, unless you specifically change stories.

Here's a way to get to your controls in the header:

Dim ad as Document
Set ad = ActiveDocument
For Each objCC In ad.Sections(1).Headers(wdHeaderFooterPrimary).Range.ContentControls 
    ''# Do your thing 
Next

visual studio 2008 - Target header and footer Content Controls in Word...

visual-studio-2008 ms-word contentcontrol
Rectangle 27 0

So the trick is in changing the TargetControlId property of the animation as you guessed. While it's not as easy as jQuery's $["#MyControl"].hover(function {}); syntax it can be done.

There's a couple of hidden properties on the javascript objects that you need to use. The _onHoverOver, _animation, and _target properties, specifically.

For example let's say that you have a button that you'd like to resize if somebody hovers over it, you'd need to create your animation extender and a couple of javascript calls that you reference in your onmouseover event:

<ajaxToolkit:AnimationExtender id="aeAnimateClaimButtons"
    runat="server" BehaviorID="showHover" TargetControlID="ctlNonExistent" >
    <Animations>
      <OnHoverOver>
        <Sequence Duration=".4">
          <Resize Width="500" Height="100" Unit="px" />
        </Sequence>
      </OnHoverOver>
      <OnHoverOut>
        <Sequence Duration=".4">
          <Resize Width="200" Height="100" Unit="px" />
        </Sequence>
      </OnHoverOut>
    </Animations>
  </ajaxToolkit:AnimationExtender>
<script type="text/javascript">
    function hoverOverButton(senderId) {
      var ae = $find("aeAnimateClaimButtons");
      ae._onHoverOver._animation._target = $get(senderId);
      ae._onHoverOver.play();
    }

    function hoverOutButton(senderId) {
      var ae = $find("aeAnimateClaimButtons");
      ae._onHoverOut._animation._target = $get(senderId);
      ae._onHoverOut.play();
    }
  </script>
<input type="button" onmouseover="hoverOverButton(this)" onmouseout="hoverOutButton(this)" />

A word of caution here. The ctlNonExistent thing will probably make your page throw an exception. This is just an example to demonstrate the principle. Also I don't know if the _variables will end up disappearing. They don't seem like public API stuff to me.

c# - Multiple target controls for ASP.net AJAX animation? - Stack Over...

c# asp.net asp.net-ajax
Rectangle 27 0

Private Sub browser_NewWindow(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles browser.NewWindow
    e.Cancel = True
    browser.Navigate(browser.StatusText)
End Sub

Really simple, if the status text is the url (which it always is for the documents I am browsing)

Hack of the day. I've used it, and I'm happy

vb.net - Change target of links in WebBrowser control - Stack Overflow

vb.net webbrowser-control
Rectangle 27 0

This is pretty simple, in concept. Just have the NPC similar to the player class, in that it accepts control whenever something is true. For example:

class NPC {
static bool isBeingControlled = false;
public void OnUpdate() {
    if (isBeingControlled)
    {
        //set camera position to NPC position (make sure you're using NPC as an instantiated class)
        //accept key input WASD or whatever you are using and move NPC according to input.
    }
}

You'll have to instantiate NPC for each NPC you have in your game.

c# - UNITY3D: Change player control to a target model (FPS) - Stack Ov...

c# unity3d
Rectangle 27 0

I have resolved the issue by below changes:

Debug.AspNetCompiler.TargetPath = c:\ccnet\PrecompiledWeb\SampleWeb\
Release.AspNetCompiler.TargetPath = c:\ccnet\PrecompiledWeb\SampleWeb\

msbuild - Cruise control ASPNETCOMPILER : error ASPRUNTIME: The precom...

msbuild cruisecontrol.net clearcase
Rectangle 27 0

Doing a Google search, the answers (e.g. this SO thread) suggest that you made some changes that upset svn (e.g. made a modification to a file, then moved it without committing in-between).

The best fix I could find so far is to make a fresh check-out of trunk, manually merge changes to it (e.g. via WinMerge if you are on Windows) -- making commits on the way between different kinds of changes to the same file/directory -- from your current working copy; then commit that checkout. (At this point you can either replace your current working copy with this modified fresh checkout or discard all changes in the working copy and do an update on it to make it in-sync with the changes you have just committed)

Thanks for the response, but I'm looking for a way to solve this problem without doing a fresh checkout.

@darryn.ten - Just out of curiosity: What's wrong with the fresh copy approach?

Lack of disk space, the size of the trunk and the speed (haha) of svn.

version control - Best way to resolve svn "Two top-level reports with ...

svn version-control
Rectangle 27 0

I downloaded the most recent version of DVD-lab (2.0) and my script worked fine after making the adjustments to the GUI changes in version 2.0. The version 2.0 of the program did NOT need to be installed using compatibility mode. It appears that the app installed in 'compatibility mode' resists automation. I'm guessing that this is a windows 8.1 security 'feature'.

If there is a thread started regarding using autoit on programs installed in compatibility mode, I'd appreciate it if someone would include a link to it in the comments or an alternate answer.

automation - AutoIt in Window 8.1: AutoIt can't control target app (DV...

automation autoit
Rectangle 27 0

I had this problem, and I did not realize that I had uninstalled Internet Explorer. If you have, nothing will ever happen, since the WebBrowser control only instantiates IE.

Actually, it's the other way around -- IE instantiates the same engine as the WebBrowser control :)

.NET C#: WebBrowser control Navigate() does not load targeted URL - St...

c# .net control browser navigateurl
Rectangle 27 0

You can use anchors and use it to target your iframe

<a href="http://www.google.com" target="thisframe">Google</a>
<iframe name="thisframe" src="http://www.yahoo.com"></iframe>

As far as i know, you can never target *div*s unless you use javascript to manipulate the DOM, though. But if you really REALLY had to use the HyperLink control instead, the you can use the following code instead of using the anchor:

<asp:HyperLink ID="uxHyperLink" runat="server" Target="thisframe" NavigateUrl="http://www.google.com">Google</asp:HyperLink>
<iframe name="thisframe" />

vb.net - how can i make a div target of a asp.net hyperlink control - ...

asp.net vb.net vsts2008
Rectangle 27 0

If will not only take you to a page but scroll your browser down to the "videos" section onthe page.

In the url (the link) notice the /#videos. That is the bookmark. On the target page in question I have an anchor tag with it's name attribute set to "videos"

I'm using square brackets above because of the editor not allowing anchor tags. So basically, just above your "target" div, place an anchor tag and set the "name" attribute. Then you your link simply append the /#anchorname at the end of the url.

vb.net - how can i make a div target of a asp.net hyperlink control - ...

asp.net vb.net vsts2008
Rectangle 27 0

First i would make sure that the security of the site within the IFrame allows you to do this kind of stuff. Check out this link: Overcoming "Display forbidden by X-Frame-Options"

Next, i would worry about the target of your anchor tag. With specifying it will default to self. In your second piece of code the target will be _self. Thus, when you click the link your javascript will want to change the source of the IFrame while the link will want to change the entire page. I would pick either a JS or HTML implemetation of linking and not both. Here is something that i put together to show one way of changing the iFrame without an actual anchor tag.

<html>
<body>

<iframe id="frameName" src="page.html"></iframe>
<button onclick="changeFrame()">LINK</button>
<script>
    function changeFrame() {
          document.getElementById('frameName').src ='page2.html';
      }
</script>


</body>
</html>

target - Control one iFrame from another iFrame - Stack Overflow

iframe target
Rectangle 27 0

If you are targeting Windows XP SP2 or later, you can catch the NewWindow3 event to get the target url, and after setting the cancel parameter, navigate to the url instead.

For earlier versions of IE you can catch the obsolete NewWindow event with the same handling as documented in Q185538 How To Cause Navigation to Occur in Same WebBrowser Window

vb.net - Change target of links in WebBrowser control - Stack Overflow

vb.net webbrowser-control
Rectangle 27 0

I rewrited example you found to change anchor target, now links are opened in same window. But this method has limitations - only static links are fixed, any JS methods trying to open link in new window will fail.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    initialize="init()">
<mx:Script>
<![CDATA[
    private function init():void
    {
        html.htmlText =
            "<html><body>" +
            "<a href='http://adobe.com' target='_blank'>Adobe (blank)</a><br/>" +
            "<a href='http://ixbt.com' target='_self'>iXBT (self)</a>" +
            "</body></html>";
        html.addEventListener(Event.COMPLETE, onHTMLComplete);
    }

    private function onHTMLComplete(event:Event):void
    {
        var document:Object = html.domWindow.document;
        for each (var anchor:Object in document.getElementsByTagName("a"))
        {
            if (anchor.hasOwnProperty("target"))
            {
                if (anchor.target == "_blank")
                {
                    anchor.target = "_self";
                }
            }
        }
    }

]]>
</mx:Script>
    <mx:HTML id="html" width="100%" height="100%"/>
</mx:WindowedApplication>

Hi Alla and Alxx: I again stuck with an-other issue. If HTML page is divided into farmes, then clicking on link of frame does not reload the page, so Complete event is not triggered. So any link with target="_blank" is unable to open :(. Can you help me on this issue too?

actionscript 3 - AIR HTML Control Issue (Its not opening links that ha...

actionscript-3 air flash-builder flashbuilder4 flash-cs5