7 Replies - 1364 Views - Last Post: 05 June 2009 - 12:51 AM Rate Topic: -----

#1 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 173
  • View blog
  • Posts: 1,094
  • Joined: 10-December 08

Editing the webbrowser control

Post icon  Posted 03 June 2009 - 11:55 AM

Is it possible for me to edit the System.Windows.Forms.Browser? If so, how can I do it?
Is This A Good Question/Topic? 0
  • +

Replies To: Editing the webbrowser control

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 765
  • View blog
  • Posts: 5,095
  • Joined: 08-December 08

Re: Editing the webbrowser control

Posted 03 June 2009 - 12:06 PM

No, you can't directly edit the control. It is a standard .NET library and you can only change its open properties in your own application.
Was This Post Helpful? 0
  • +
  • -

#3 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Editing the webbrowser control

Posted 03 June 2009 - 01:14 PM

Do you mean edit the content of the displayed web page? Or enter text/clicks into a webage?
Was This Post Helpful? 0
  • +
  • -

#4 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 173
  • View blog
  • Posts: 1,094
  • Joined: 10-December 08

Re: Editing the webbrowser control

Posted 03 June 2009 - 01:48 PM

What I am realy getting at is how can I change the dialog box which comes up on the download event?
Was This Post Helpful? 0
  • +
  • -

#5 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 765
  • View blog
  • Posts: 5,095
  • Joined: 08-December 08

Re: Editing the webbrowser control

Posted 03 June 2009 - 01:51 PM

In this case you will probably have to handle web requests ( http://msdn.microsof...webrequest.aspx ). You will need to actually capture whenever a user presses a download link and then create a request by yourself instead of letting the control handle it.
Was This Post Helpful? 0
  • +
  • -

#6 mark.bottomley  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 990
  • Joined: 22-April 09

Re: Editing the webbrowser control

Posted 03 June 2009 - 05:32 PM

To play with web pages, you will usually need to look at the source to get things like the name of the input field. Problem is that not all websites consistently name their fields and buttons etc. You can use Focus() followed by SendKeys, but it is very unreliable!

Assuming you can get a name of the field, you can do the following:
...
		Dim mText As String = "text for box"
		Dim mField As String = "input_box" ' the name attribute in the HTML source

		Dim inputField As HtmlElement = Nothing

		' Returns first element of that name - expected to be unique most times
		Dim elementsEnumerator As IEnumerator = elements.GetElementsByName(mField).GetEnumerator
		If elementsEnumerator.MoveNext() Then
			inputField = CType(elementsEnumerator.Current, HtmlElement)
		End If
		If Not IsNothing(inputField) Then
			inputField.InnerText = mText
		End If


Was This Post Helpful? 0
  • +
  • -

#7 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 173
  • View blog
  • Posts: 1,094
  • Joined: 10-December 08

Re: Editing the webbrowser control

Posted 04 June 2009 - 04:46 AM

I have this code which I am trying to use, which cancels the Link Click event on my browser:
	Private Sub LinkClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
		href = Me.document.ActiveElement.GetAttribute("href")
		If href.ToUpper.Contains(".wmv".ToUpper) Then
			MediaPlayer.Show()

			MediaPlayer.BringToFront()
			MediaPlayer.AxWindowsMediaPlayer1.URL = href
		ElseIf href.ToUpper.Contains(".exe".ToUpper) Then
			Me.AllowNavigation = False
			e.Cancel = True
			Form1.DownloadTimer.Start()
		Else
			Me.Navigate(href)
		End If
		System.Threading.Thread.Sleep(500)
		Me.AllowNavigation = True
	End Sub



But it does not work :(

Has anyone got any ideas?
Was This Post Helpful? 0
  • +
  • -

#8 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 173
  • View blog
  • Posts: 1,094
  • Joined: 10-December 08

Re: Editing the webbrowser control

Posted 05 June 2009 - 12:51 AM

Has anyone got any ideas?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1