Windows Phone 7 browser control with additional script running in browser - c#

I am developing a windows phone application in visual studio (Silverlight in C#) and I added a browser control to the application that i develop to show some random website.
Now i need to run a javascript along with that page in the browser control. How do i add the script to that. is there anyway to append the script directly when the html loads?
The script can be loaded from remote server or from the application itself. Its just to modify the pages a bit and display.

Instead of using the NavigateTo(URI) method of the WebBrowserControl directly with the URL, you can get the source of the HTML page as a string, modify it by injecting your javascript and use the NavigateToString(string html) method to display the content.

Related

Loading jQuery in a C# windows form application

I'm making a Windows Form application that makes use of the browser tool. The browser does not connect to the internet and is only used to load local HTML content.
It's loading HTML CSS and JavaScript fine, but It cant seem to recognise jQuery. Is there a simple way for MVS to recognise jQuery as a script? All of the errors are related to it not understanding jQuery methods.
JQuery is supported form internet Explorer: 9+
when you use WebBrowserControl you get browser emulator ie 7,
change your regEdit key according with Use latest version of Internet Explorer in the webbrowser control

Any way to automate IE *WITHOUT* using webbrowser control?

I have an enterprise app that automates many business functions. I make heavy use of the WebBrowser control for all of my web site interactions (web site scraping, web app automation, etc....)
I've come across two web sites that simply will NOT render properly in the WebBrowser control. Specifically:
the US Postal Service Click-N-Ship web app. Renders fine until it is time to pay for your postage. Even just using the mouse to control it within a WebBrowser control (no automation) will not allow me to pay for postage. Soon as I submit the page it just hangs forever.
the UPS Quantum View Manage web app. This page will not even LOAD in the WebBrowser control. Just hangs forever.
Both of these render just fine in my IE10 browser.
I have tried setting the registry keys to change the rendering engine from default IE7 to IE9. But still same results. Something about these web apps just will not render in the WebBrowser control.
So....is there any way to automate IE10 the browser from my C# app? By sending messages of some sort? I need to be able to click links and fill in form data for login info and such. Any advice appreciated...
You could use a testing tool like Selenium to automate IE. You can download the IE Driver from their downloads page.
A simple example using google (Make sure you read the instructions on how to get the IE Driver working):
OpenQA.Selenium.IE.InternetExplorerDriver d = new OpenQA.Selenium.IE.InternetExplorerDriver();
d.Navigate().GoToUrl("http://www.google.com");
d.FindElementByName("q").SendKeys("Stack");
d.FindElementByName("btnK").Click();
WebDriverWait waiter = new WebDriverWait(d, TimeSpan.FromSeconds(10));
waiter.Until(ExpectedConditions.ElementExists(By.CssSelector(".rc .r a")));
// Message the first element
MessageBox.Show(d.FindElementByCssSelector(".rc .r a").Text);

How to allow blocked content in an embedded Webbrowser in c#?

I'm developing a c# application that embeds the Webbrowser control. I create the Website dynamically and use NavigateToString() to display it. I'm on Windows 8 with IE10.
Now my Problem is: Javascript won't execute. For example I added a link that calls alert and another one that calls reset() on a form. Both do nothing. I believe it has to be some security issue because when I say the generated page and open the file manually in IE10 and click one of those links, I get a popup at the bottom that says "Internet Explorer restricted this Webpage from running scripts or ActiveX controls." and a "Allow blocked Content"-button. If I just Close the popup, nothing happens, if I click "Allow blocked Content" the JavaScript works fine.
How can I enable JavaScript in the embedded Webbrowser?
How are you accessing this local website? is it localhost? you need to make the url security friendly so it doesn't get blocked, give it a url http:// localhost:someport instead and it should work

Hosted WebBrowser control attempts to download Flash content rather than playing it

I am hosting an IE browser control in a simple, .NET winforms app. When I make the control navigate to certain content on disk, the control attempts to download the file (rather than displaying the content.) The exact same URL when pasted into the IE browser will properly display the swf file in question along with processed XML data that is passed as a parameter.
Abbreviated example of the URL:
file:///C:/...SomeSwfFile.swf?dataXML=%3C ... assume well-formed XML here
What can i do to get the browser control to behave just like the IE application with that type of URL?
Additional per feedback: HTML files are loaded into the control just fine.
The issue was that i was trying to host a Flash control inside a web browser control built on a x64 dev box. At this point in time Flash doesn't do well in 64 bit processes. When i set the app to build for x86 everything worked fine.

Load ASPX page to a windows webbrowser control

Hi I have a Windows form the import data to SQL, also I have an aspx page which is used for previewing data which i need to load to to the windows form using WebBrowser Control, my problem is that How do I pass a collection (List) to the aspx page for it to be able to bind to a gridview?
You can't - they are separate things.
The WebBrowser control simply renders an IE window on your form, loading the requested page and rendering it as usual.
If you want to pass data to the webpage from the web application, you will need to get the data to whichever data source (ie: common database etc) the web app reads from then refresh the web page which will read the new data.
Look at ASP.NET application hosting.
There are a couple of examples already written, so you do not have to re-invent all the glue.
Here is the code I used for IronScheme's 'document browser'.
Here you can see how I setup the server part in a simple console app, but creating a windows forms one is not hard.
As for passing data, you can simply just dump it in the ASP.NET application state, and then read that back from within your ASPX page.

Categories

Resources