C# Webbrowser Element displays HTML Table differently - c#

I'm displaying a HTML page containing a table in my webbrowser element on a windowsform. However some parts of the table appear differently in the webbrowser element than when I open the HTML file with any browser (including IE).
Here is the comparison:
http://imgur.com/a/1QRs1
Top: Any browser ,
Bottom: Webbrowser Element
(In case the link dies someday : some borders appear thicker than they should and vertical text is displayed as horizontal text).
Is there any way to fix this? What might cause this?

The WebBrowser control is by default set to emulate IE7, which is probably the cause for this. You can change the IE-Level used for the WebBrowser control by creating a registry entry, though it must be set for each individual executable.
For more details (like the exact registry key and possible values) see the following article on Code Project: Configuring the emulation mode of an Internet Explorer WebBrowser control

Related

Textbox border becomes thicker after rendering RDLC report to pdf

I am making rdlc report and I am rendering it to pdf, but for some reason textboxs' borders become thicker after this process. More strange is that if I copy (only location and ZIndex properties change) one of the textboxes (which border becomes thicker) in another place, the border of copied textbox isn't thick.
This is the result.
This is problem only in Microsoft edge (while opening generated pdf file in it). My report looks nice in Opera and Google Chrome browsers. I tried to report this problem to Microsoft, but their web page told me that it wasn't able to identify I was person or not.. :)

Internet Explorer PDF Reader

I apologize for the length of this question, but some background explanation is required.
Background:
I'm working on an internal web application that will display a pdf in an iframe. Adobe Reader X offers a "Read Mode" for displaying the pdf in the browser. This removes the shell and adds a menu box to the bottom of the pdf when the mouse is over the "middle center". In versions prior to X you could use JavaScript to modify the toolbar menu items.
What I Need:
I need to display the pdf in "Read Mode" AND remove all menu items. The computers that are to run this app are basically a kiosk and are literally a computer, monitor and mouse. No printers, no keyboard, no other interactivity.
My question is this:
How can I load a pdf for reading in internet explorer, and disable all interaction except scrolling. That is, no menus, no context menu, and no "shadow bar" when the bottom center is moused over. I've been searching for alternatives to Adobe, and there are some great ones, but the ones I've found that have a browser plugin, do not have a plugin for IE.
If someone know a way to just load the PDF Contents that would be an even better route.
More Information:
If it helps, while this is being built for Internet Explorer, the web-page will be loaded into a windows form that is just a full-screen browser control.
Other things I've tried:
I have also tried positioning a transparent iFrame on top of the pdf iFrame, covering only the displayed content, but leaving the scrollbars intact. This worked perfect if I loaded anything BUT a pdf. If I loaded any other website then it worked as expected (except the scroll wheel of course doesn't scroll the webpage). If a pdf was loaded, then all that would appear is a white square. Use the dev toolbar to remove the transparent iFrame and the PDF looks good.
I've found a good partial solution. A product called PDFObject.
Using it, I can add the following JavaScript to my page:
function embedPDF() {
var myPDF = new PDFObject({
url: 'PathToPdf.pdf',
pdfOpenParams: {
scrollbars: '1',
toolbar: '0',
statusbar: '0',
messages: '0',
navpanes: '0'
}
}).embed('DivToLoadPdfInto');
}
window.onload = embedPDF;
This will embed the pdf into a div and remove the toolbar, statusbar, message, navpanes, but still allow scrollbars. This prevents the shadow box menu from appearing, which is great!
Users can still right-click on the pdf so I'll try the standard Right-Click blockers in JavaScript and edit if I can get something to work.
Edit:
A good resource for URL Parameters can be found here.
Ok, so I have come up with a final solution.
Needs:
Load PDF in iFrame in "Reader Mode" but with no shadow bar
PDF Context Menu should be disabled
Addressing the first need is easy with some caveats. Set the source of the iFrame to "pathToPdf/document.pdf#toolbar=0&navpanes=0". The caveats here are that (in IE at least) once this breaks, then the browser needs to be closed and re-opened to work again. So, what can break it?
User right clicks and opens the navigation pane buttons.
User presses the escape button on the keyboard.
The webpage is loaded into the browser control of a windows form, and luckily once broken there it works fine without closing and reopening. Could still be a problem though for the PDF being viewed. I don't have to worry about the escape key, because the app is running on a KIOSK(basically) and there is no keyboard, only a mouse.
Disabling the context menu has proved to be the most difficult thing to do. The web browser control has a "IsWebBrowserContextMenuEnabled" property that when set to "False" will disable the context menu for the browser. Probably because the adobe reader is a plugin, this does not effect the PDF. With Reader X there is no registry setting (that I could find) or JavaScript method, or general setting that will disable context menu.
I was ready to give up when I remembered something. This is a kiosk, and there is no need for the right mouse button. So the solution; modify the registry and turn off the right click for the internal OS. To do that simply open regedit and goto:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
Find (or create if it is not there) a DWORD key named "NoViewContextMenu".
A value of 1 will disable right clicking, 0 will enable.
Summary:
Use "pathToPdf/document.pdf#toolbar=0&navpanes=0"
Disable right click in windows registry
Edit:
The registry hack only disables the right mouse button in windows explorer. We are having no luck in finding a good software solution, so we are left with either writing our own custom mouse drivers or simply popping open the mice and removing the physical trigger mechanism.

Change SQL Server Report Viewer Control color properties?

I'm using asp.net and report viewer control in a web page. I want to format its colors to match the page.
What properties do I need to set to change the backcolor or other style properties of the below image only(it appears inside the report viewer control)? Can I change them from the reportviewer control or do I need to edit the markup of the .RDL file? If these properties can be changed in the RDL file where should I look to change them?
Please, I only want to know if I can change the colors/properties of what I show in the image below. Thanks
You could look at the styles used by the control when it's rendered on the page and override them on your own CSS file. Just make sure you reference your css file on the page containing the report viewer control.
Worst case scenario, you can apply your own styles using jQuery. All you need to know is the ids or classes (or whatever selector is appropriate) of the html elements when the control is rendered.
The bottom line is that you can accomplish this because the report viewer control is not some sort of ActiveX control or Applet of any sort. The only thing on this control that actually uses an ActiveX control is the "print" icon, which, if I recall correctly, can send the output directly to the default printer w/o asking you to select one when used within Internet Explorer. On other browsers, doesn't even render the print icon.

Printing in landscape from a Windows Forms WebBrowser control

I have a WebBrowser control in a Windows Forms Host in a WPF application. I know that in order to print it's contents, I use simply WebBrowser.Print(), however, how can I tell the printer to print the contents in landscape rather than a portrait orientation? I've been searching the Internet on this and oddly enough, it seems to be actually something that is a bit hard to do -- is this really the case? It seems odd to me that it wouldn't be easily implementable.
Thanks!
INFO: WebOCHostCSharp.exe Hosts the WebBrowser Control in C# .NET
http://support.microsoft.com/kb/326217
The Print(String) method prints a document and does not display a dialog box. This method uses a Microsoft HTML (MSHTML) print template to automatically control print options such as paper size, orientation, and number of copies.
Note: This project does NOT contain this mystery overloaded method "Print(string)", It's actually called "PrintFormatted(string)"

UI Automation cannot control embedded browser

This is about testing a desktop application. I have been trying to click a hyperlink on an embedded browser of a Windows form. I could move the mouse anywhere if the component (buttons, or whatever) is part of the form, but elements inside the browser, i can't seem to control at all....sigh.....yes, I could move the mouse if I use the screen coordinates but I plan to control the embedded browser using Watin, etc..without opening a new IE....Using Microsoft's UISpy tool (when I hover the cursor to the link..it shows a Pane ControlType)....the hyperlink is part of the tree structure but only the name property is available...some of the parent's properties are blank....
I tried extending the example from the link below
http://archive.msdn.microsoft.com/uiautomation
and this is where i'm stuck (I have tried FindChildByName and other related methods too...sigh..no luck):
var commontab=AutomationElement.RootElement.FindFirstChildHavingDescendantWhere(new[] { new PropertyCondition(AutomationElement.NameProperty, "Search")});
Mouse.MoveTo(menutab.GetClickablePoint().ToDrawingPoint());
Mouse.Click(MouseButton.Left);
Somehow the mouse cannot find the 'Search' hyperlink...sigh...please guys...any ideas??
Would it not be a simpler idea to split this into 2 testing strategies? The first is testing the desktop UI, buttons etc. as you are. The second is to test the html which is to be placed within the embedded browser frame.
You shouldn't be testing that the embedded browser works, that's Microsofts job. The only testing that you may want to do on the frame is to ensure that it's content is loaded, that the call is to the correct (internal) url etc.

Categories