473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

WebBrowser control Navigation

Hello everyone,
I am developing one win application which makes use of WebBrowser control.I am passing the url in a text box and the page is getting displayed in the web browser control.Till this its fine.Whn ever a link is clicked inside the webbrowser control it is opening in the same page.Is there any way such that the clicked links inside a webbrowser control should open in a new tab with the tab having the page title.

I tried the following code:
Expand|Select|Wrap|Line Numbers
  1. TabPage newPage = new TabPage("New Page");
  2. tabControl1.TabPages.Remove(newPage);
  3.  
  4. WebBrowser wb = new WebBrowser();
  5. wb.Size = tabControl1.Size;
  6. wb.Navigate(webBrowser1.StatusText.ToString());
  7. TabPage tp = new TabPage();
  8. tp.Controls.Add(wb);
  9. tp.Tag = wb;
  10. tabControl1.TabPages.Add(tp);
  11.  


But this is not working ...Anyone having any sugessions / ideas how this can be done ???

Thanks in advance
Bryan
Jul 19 '08 #1
3 2175
kenobewan
4,871 Expert 4TB
Define "But this is not working", did you get an error?
Jul 20 '08 #2
Hi ,
I am not getting any error, new tab is getting opened but the page still opens in the same webbrowser control.Any one please help ...

I in fact tried this code in the navigating event of web browser.But it is also opening a new tab and inthe browser which is newly created is having the message "action cancelled".
The clicked url is getting opened in the 1st browser control...


Here is the piece of code i tried ...

Please help ...

Expand|Select|Wrap|Line Numbers
  1.    void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
  2.         {
  3.  
  4.             navigatedUrl = webBrowser1.StatusText.ToString();
  5.             int tab_count = 0;
  6.             string tabName;
  7.             tab_count = tabControl1.Controls.Count;
  8.             tabName = "TabPage" + ++tab_count;
  9.             TabPage tabNew = new TabPage();
  10.  
  11.             tabNew.Location = new System.Drawing.Point(4, 24);
  12.             tabNew.Padding = new System.Windows.Forms.Padding(3);
  13.             tabNew.Size = new System.Drawing.Size(800, 517);
  14.             tabNew.TabIndex = 0;
  15.             tabNew.Text = tabName;
  16.             tabNew.UseVisualStyleBackColor = true;
  17.             tabControl1.Controls.Add(tabNew);
  18.             tabNew.Name = tabName;
  19.             string webName = "webBrowser" + tab_count;
  20.  
  21.             WebBrowser webNew = new WebBrowser();
  22.             webNew.Dock = System.Windows.Forms.DockStyle.Fill;
  23.             webNew.Location = new System.Drawing.Point(3, 3);
  24.             webNew.MinimumSize = new System.Drawing.Size(20, 20);
  25.             webNew.Name = webName;
  26.             webNew.Size = new System.Drawing.Size(794, 511);
  27.             webNew.TabIndex = 0;
  28.             webNew.AllowNavigation = true;
  29.             tabNew.Controls.Add(webNew);
  30.              webNew.Navigate(navigatedUrl );
  31.         }
  32.  
  33.  
Jul 26 '08 #3
Any one...Plz....help me on this ...
Jul 26 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jim Hubbard | last post by:
According to Visual Studio 2003 Help files "In Internet Explorer 6 or later, the BeforeNavigate2 event fires only before the first navigation made in code. It does not fire when a user clicks a...
2
by: frederik12 | last post by:
Hi all, Today I downloaded and installed VS 2005 C# Express Edition (.NET framework 2.0). I'm very pleased about this new product. In my current application I'm using the WebBrowser control in...
8
by: Vibor Cipan | last post by:
Hi I have two webbrowser controls on my form web1 and web2. I load some HTML in web1, and that HTML file contains links. How to make following thing - when i click on link in web1 control, to...
2
by: cweeks78681 | last post by:
I am porting some VB6 code that automates navigation through a web page by getting all the <a> tags into a collection and then calling the Click method on the appropriate one. How do I click a...
2
by: =?Utf-8?B?c25naWxi?= | last post by:
The WebBrowser control is described as exposing numerous public mouse events. See: http://msdn2.microsoft.com/en-us/library/ayestehw.aspx. many of the event are described as: "This event is not...
6
by: titan.nyquist | last post by:
The WebBrowser control won't load a css file written in the same directory as the program. If I put an absolute path to it, it will load it. Thus, the current directory of the WebBrowser control...
3
by: sonicwrx | last post by:
Am I missing something? I have a form with a browser control and a button. The code under the button is: private void btnGo_Click(object sender, EventArgs e) { wbScrape.Navigate(@"http://...
2
by: M R | last post by:
i am writing an application (C#) that automates the process of loading a web page, login into a site and then simulates the navigation of the site. the program uses a winform with a webBrowser...
17
by: Cesar | last post by:
Hello people. I'm having a Winform app that contains a webbrowser control that keeps navigating from one page to another permanentrly to make some tests. The problem I'm having is that after a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.