From: Ed on
// I was going to use the browser control to display
// a print preview and made this prototype.
// The key is the base href in the header

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace CFWBPrintPreview
{
public partial class PrintPreview : Form
{
const string file = @"img001.jpg";
string filePath;

public PrintPreview()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
filePath = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
filePath = Path.GetDirectoryName(filePath);
string Head = "<head><title>Print Preview</title><base href=\"file://localhost"+filePath+"/\" /></head>";
string Body = "<body><b><center>Bold Test of the Printer</center></b><br />" +
"This is just a standard line. <u>Underlined</u><br />" +
"Signature <img src=\"" + file + "\" alt=\"img001.jpg\"></body>";
webBrowser1.DocumentText = Head + Body;

}
}
}



Paul G. Tobey [eMVP] wrote:

The device vendor has chosen Opera Mobile as the browser and implemented
15-Jan-10

The device vendor has chosen Opera Mobile as the browser and implemented the
WebBrowser control interface (see my other message), in terms of Opera, not
Internet Explorer Mobile. As a result, different things happen when you do
operations. As you see, Opera opens, presumably because it runs only as a
separate application, not as an embeddable control. The device vendor may
have provided some way to switch the default browser, which might work for
you, if you can live with changing a global setting on the device...

Paul T.

"badzio" wrote:

Previous Posts In This Thread:

On Tuesday, January 12, 2010 9:56 PM
badzio wrote:

Webbrowser, DocumentText and local image
Hi,

I have new problem with WebBrowser :)
I generate html document at runtime and display it in webbrowser using
code:
WebBrowser webbrowser;
String myHtmlDoc;
webbrowser = new WebBrowser();
myHtmlDoc = @"<html>message to display <img='\temp\image.png' \></
html>";
webbrowser.DocumentText = myHtmlDoc;

the result is:
I see text 'message to display' but instead of image I see 'red X' -
you know, the image which is shown when browser cannot find the image
to display.
Ofcourse path \temp\image.png is valid, this file exists.
If I create a document on the device with mentioned content and load
it to webbrowser (using Navigate()) than image is displayed.
If I use image from network:
myHtmlDoc = @"<html>message to display <img='http://server/image.png'
\></html>";
than the image is displayed.
Seems that in DocumentText cannot contain reference to image on the
device. Does anybody know how to solve that problem?

On Wednesday, January 13, 2010 2:02 PM
Paul G. Tobey [eMVP] wrote:

Wouldn't that need to be "file://temp/image.png" or something like that?
Wouldn't that need to be "file://temp/image.png" or something like that? The
problem is likely to be that the WebBrowser does not know what the root path
from which the HTML was loaded is, so it cannot interpret \temp\image.png.
That is \ related to where? What server? There might be some way to tell
the WebBrowser object that information before you set up the document text, I
suppose...

Paul T.

"badzio" wrote:

On Thursday, January 14, 2010 4:33 PM
Paul G. Tobey [eMVP] wrote:

I guess that, if you have checked everything that could work for the case
I guess that, if you have checked everything that could work for the case of
setting the document text explicitly, maybe you should look at other methods
of getting the browser object to load your generated page (generate it to
disk and point the browser to it, etc.)

Paul T.

"badzio" wrote:

On Thursday, January 14, 2010 5:39 PM
badzio wrote:

I did not find any method to tell WebBrowser what is the root.
I did not find any method to tell WebBrowser what is the root. file://
didin't help.

On 13 Sty, 20:02, Paul G. Tobey [eMVP] <paultobey _at_ earthlink _dot_
net> wrote:
=A0The
th
=A0
tell
t, I
g'

On Thursday, January 14, 2010 11:02 PM
Paul G. Tobey [eMVP] wrote:

Some versions do, some not.
Some versions do, some not. Without knowing what version you are talking
about, I do not think there is an answer.

Paul T.

Another question - does WebBrowser support javascript? If yes, than is
any event called when <img /> element got focus?
I have checked with onfocus and onactivate - does not work.
I use smartphone so focus in html page is changed by cursors. I'd like
to change source image when <img /> is selected.

On Friday, January 15, 2010 12:35 AM
badzio wrote:

Yeah, I have solved that problem by writing html on the device and loadit from
Yeah, I have solved that problem by writing html on the device and load
it from local storage. Hope that client'll accept creating temporary
file :)
But if anybody solve that problem another way, I'd be greatful


On 14 Sty, 22:33, Paul G. Tobey [eMVP] <paultobey _at_ earthlink _dot_
net> wrote:
f
ods
at? =A0The
t path
png. =A0
y to tell
text, I
ing
-
ge
d
e.png'

On Friday, January 15, 2010 12:35 AM
badzio wrote:

Another question - does WebBrowser support javascript?
Another question - does WebBrowser support javascript? If yes, than is
any event called when <img /> element got focus?
I have checked with onfocus and onactivate - does not work.
I use smartphone so focus in html page is changed by cursors. I'd like
to change source image when <img /> is selected.

of
thods
to
_
that? =A0The
oot path
e.png. =A0
way to tell
nt text, I
using
\></
' -
mage
oad
age.png'
he

On Friday, January 15, 2010 7:36 AM
badzio wrote:

Something strange.. this solution works fine on emulator.
Something strange.. this solution works fine on emulator.
On SPV e650 browser does not show page loaded from local storage.
Display is empty. I load:
browser.Navigate(new Uri("\\temp\\page.html"))
path is valid because if I use incorrect filename than webbrowser
shows error 'not found'
If I load page from internet - that is ok.

of
thods
to
_
that? =A0The
oot path
e.png. =A0
way to tell
nt text, I
using
\></
' -
mage
oad
age.png'
he

On Friday, January 15, 2010 7:36 AM
badzio wrote:

How to check the version?
How to check the version? it is webbrowser from CF .Net, which I use in
visual studio. Tested on emulator WM6 professional.

On 15 Sty, 05:02, "Paul G. Tobey [eMVP]" <paul tobey _AT_ earthlink
_DOT_ net> wrote:
g

On Friday, January 15, 2010 7:36 AM
badzio wrote:

More details.
More details. On SE xperia is launched Opera Mobile to open html from
local storage.
so:
browser.Navigate(new Uri("\\temp\\page.html"))
on spv e650 nothing happens, on xperia Opera Mobile is launched
browser.Navigate(new Uri("http://www.google.pl"))
on e650 and xperia embedded webbrowser, control from application, is
used
Why?

se of
methods
t to
/
ot_
e that? =A0The
root path
age.png. =A0
e way to tell
ment text, I
r using
g' \></
X' -
image
load
image.png'
the

On Friday, January 15, 2010 12:09 PM
Paul G. Tobey [eMVP] wrote:

The browser is permanently linked to the OS version.
The browser is permanently linked to the OS version. If you have Windows
Mobile 5, you can never add to that the browser from Windows Mobile 6.1, say.

The WebBrowser control in .NET CF is just a thin wrapper around the actual
WebBrowser control used in Internet Explorer Mobile on the device. It has no
significant functionality of its own. There should be at least some
JavaScript support in the WM6.1 version of the browser. You may be able to
find a list of supported script statements online...

Paul T.

"badzio" wrote:

On Friday, January 15, 2010 12:11 PM
Paul G. Tobey [eMVP] wrote:

The device vendor has chosen Opera Mobile as the browser and implemented
The device vendor has chosen Opera Mobile as the browser and implemented the
WebBrowser control interface (see my other message), in terms of Opera, not
Internet Explorer Mobile. As a result, different things happen when you do
operations. As you see, Opera opens, presumably because it runs only as a
separate application, not as an embeddable control. The device vendor may
have provided some way to switch the default browser, which might work for
you, if you can live with changing a global setting on the device...

Paul T.

"badzio" wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Server Side Processing in ADO.NET/WCF Data Services
http://www.eggheadcafe.com/tutorials/aspnet/db179aed-47fa-4f86-a4bf-4f6f92a76585/server-side-processing-in.aspx