Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 53073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:00:23+00:00 2026-05-10T17:00:23+00:00

We have a windows application that contains an ActiveX WebBrowser control. As part of

  • 0

We have a windows application that contains an ActiveX WebBrowser control. As part of the regular operation of this application modifications are made to the pages that are displayed by the ActiveX WebBrowser control. Part of these modifications involve setting a JavaScript variable in a web page being loaded into the ActiveX WebBrowser.

We need to initialize this variable within C# (originally, VB6 code was initializing the value). The value of this variable is a COM-visible class object.

However, for simplicity we’ve reduced the problem to setting a string value. Our original page involves frames and the like but the same problems happens in a page like this:

<HTML>  <HEAD>   <TITLE>Test</TITLE>   <SCRIPT type='text/javascript'>    var field = 'hello world';   </SCRIPT>  </HEAD>  <BODY>    <input type='button' value='See field' onclick='javascript:alert(field);'/>  </BODY> </HTML> 

We want to access the field variable and assign a value to it. In VB6 the code for this was pretty straightforward:

doc.Script.field = 'newValue' 

However, in C# we’ve had to resort to other tricks, like this:

Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Script, null, 'field',new object[] { 'newValue'},null, null); 

The point of the page is to test whether our variable was properly assigned by C#. Clicking on the button should yield whatever new value was injected by C#. So for example, clicking on the button in the page we get an alert showing: ‘newValue’.

That works the first time, but it doesn’t work if we reload the page. On subsequent calls we cannot set the value of the variable field.

Has anyone had any experience doing this type of operation before?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:00:23+00:00Added an answer on May 10, 2026 at 5:00 pm

    These two articles helped us find a solution to our problem. They outline the basics of what one needs to know:

    Microsoft Web Browser Automation using C#

    Using MSHTML Advanced Hosting Interfaces

    So we implemented a DocHostUIHandler interface and that allowed us to set a UIHandler, allowing us to reference the method from Javascript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 85k
  • Answers 85k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This will give you the site ID: Request.ServerVariables[ "INSTANCE_ID" ]… May 11, 2026 at 5:15 pm
  • Editorial Team
    Editorial Team added an answer See How to convert a character in to equivalent System.Windows.Input.Key… May 11, 2026 at 5:15 pm
  • Editorial Team
    Editorial Team added an answer Technically controllers are just .CS files that are put in… May 11, 2026 at 5:15 pm

Related Questions

FYI - I am a mainframer that moved to the .NET world a couple
We have a MFC 8 application compiled with /CLR that contains a larger amount
I hope everyone will pardon the length, and narrative fashion, of this question. I
In brief: Is it ever excusable to have assembly names and class names stored

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.