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 6563227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:48:18+00:00 2026-05-25T13:48:18+00:00

In my winforms aplication I have a WebBrowser control named webBrowser1. In code all

  • 0

In my winforms aplication I have a WebBrowser control named webBrowser1.

In code all I added is navigating to a page:

private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.Navigate("http://localhost:6489/Default.aspx");
}

The code for the page to which I navigate is:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TableRowShow.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
      window.onload = function()
      {
        document.getElementById('addDestination').setAttribute('onclick', 'addDest();');
      }

      function attach()
      {
        document.getElementById('addDestination').setAttribute('onclick', 'addDest();');
      }

      var i = 1; // position of next tr to be shown

      function addDest()
      {
        var trs = document.getElementById('travelTable').getElementsByTagName('tr');

        if (trs[i] != null)
          trs[i++].style.display = "";
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">
      <table id="travelTable">
        <tr>
          <td>
            <asp:TextBox runat="server" />
          </td>
        </tr>
        <tr style="display: none">
          <td>
            <asp:TextBox runat="server" />
          </td>
        </tr>
        <tr style="display: none">
          <td>
            <asp:TextBox runat="server" />
          </td>
        </tr>
      </table>
      <asp:HyperLink runat="server" ID="addDestination"
        ClientIDMode="Static"  NavigateUrl="javascript:;" >
        Add Destination
      </asp:HyperLink>
    </form>
</body>
</html>

Seen in a browser like IE or Chrome the page looks like this:

Clicking on Add Destination anchor creates a new input:

The problem that I’m having with WebBrowser control is that it loads the page but the JavaScript doesn’t work.

If I click on Add Destination nothing happens, even though the same page works well in Chrome or IE.

Placing a breakpoint and using:

webBrowser1.Document.InvokeScript("addDestination");

inside the Immediate window and then continuing to run the program activates the JavaScript in that function adding a new input.

Thanks for replies!

  • 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-05-25T13:48:18+00:00Added an answer on May 25, 2026 at 1:48 pm

    Try attaching the click handlers like this instead of using setAttribute in the onload and attach functions:

    document.getElementById('addDestination').onclick = addDest;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my WinForms application, I have a WebBrowser control which displays a page. When
I have a WinForms C# application. There is a WebBrowser control on the form
i have found that WebBrowser control (both Winforms and WPF) has certain javascript constructs
I have a C# WinForms application that has a WebBrowser control inside of it.
I have a WinForms application with a DataGridView control and a column of DataGridViewButtonCell
I am using WebBrowser control in the WinForms application. I want to write program
I have a WinForms application in which I have hosted a web page inside
In my winforms application I have some code that needs to be executed after
I have a .NET Winforms web browser control that is rendering some application information,
I am trying to change the UserAgent of the WebBrowser control in a Winforms

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.