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

  • SEARCH
  • Home
  • 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 8488421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:31:52+00:00 2026-06-10T21:31:52+00:00

can we handle the event inside the web browser control? in my case i

  • 0

can we handle the event inside the web browser control? in my case i am passing a radio button list to web browser control and want to handle the radio button change event in code behind,
i try to google it but didnt find any concrete example.

 WebBrowser.NavigateToString("<html>
<body>
<input type='radio' name='g1' value='V1'> V1<br>
<input type='radio' name='g1' value='V2' V2<br>
</body>
</html>");

how can i get change event of these radio button change in codebehind ,i can use javascript but that donot fill my objective

can any one suggest how to do this.

  • 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. Editorial Team
    Editorial Team
    2026-06-10T21:31:54+00:00Added an answer on June 10, 2026 at 9:31 pm

    Invoke C# method from Javascript

    Communication between html document and WPF requires you to have full trust between the applications. In javascript, window.external points to the external application, which you might use to invoke a method outside the WebBrowser.

    To do this you need to create an interface between the two. A helper method should be used to which could be accessed directly using Javascript. Let us look how we can achieve this using WPF WebBrowser Control.

    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    [ComVisible(true)]
    public class ObjectForScriptingHelper
    {
        Mainwindow mExternalWPF;
        public ObjectForScriptingHelper(Window1 w)
        {
            this.mExternalWPF = w;
        }
    

    }

    So basically the class allows you to invoke a .NET method directly from javascript. This helper class is set Permission to FullTrust and also ComVisible. So our WebBrowser, which is actually a Com element can directly communicate with the class to invoke method within the class ObjectForScriptingHelper, which is the parent window on which the browser is loaded. The javascript will allow to use window.external to point to this class.

    [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
    [ComVisible(true)]
    public class ObjectForScriptingHelper
    {
        Mainwindow mExternalWPF;
        public ObjectForScriptingHelper(Window1w)
        {
            this.mExternalWPF = w;
        }
        public void InvokeMeFromJavascript(string jsscript)
            {
                this.mExternalWPF.tbMessageFromBrowser.Text = string.Format("Message :{0}", jsscript);
            }
    
    }
    

    Say I have a method InvokeMeFromJavascript within the class ObjectForScriptingHelper class. To use this class you need to create an object of it and pass it to the property ObjectForScripting of WebBrowser control.

    So I write,

    ObjectForScriptingHelper helper = new ObjectForScriptingHelper(this);
    this.wbMain.ObjectForScripting = helper;
    

    Now Lets navigate to an html with :

    <input type="text" id="txtMessage" />
    <input type="button" value="InvokeMe" onclick="javascript:window.external.InvokeMeFromJavascript(document.getElementById('txtMessage').value);" />
    

    This will load a textbox and a button. See in the code above, I have used window.external to call the same function that I have declared in the ObjectForScriptHelper class. Thus when you click on the Button inside the WebBrowser, you will see the message been displayed in the TextBlock outside it.

    In the above image, when the user clicks on InvokeMe inside the WebBrowser, it will update the TextBlock placed outside.

    Source: http://www.dotnetfunda.com/articles/article840-working-with-webbrowser-in-wpf.aspx

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

Sidebar

Related Questions

How I can handle the Mouse Right Button Double Click event for a Shape
Can't work this out... I've got a .change event handler for multiple select boxes.
I have a user control inside a repeater and a custom event is raised
It is my understanding that one can handle events through Swing by adding a
How do I create a C# event handler that can be handled in IronPython?
Can I add an event handler to a session value in asp.net with c#?
How can I set an event handler (such as keydown ) to entire solution,
I have this exact issue ASP.net can’t update page from event handler and it's
In XAML you can do <TabItem Selector.Selected=myEvenHandler></TabItem> to set the event handler for when
Can anyone please explain me how is INotifyPropertChanged's PropertyChanged event is handled in the

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.