programming4us
programming4us
MOBILE

Windows Phone 7 Development : Using a WebBrowser Control to Display Dynamic Content

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
Suppose now that the user enters "Ford" in the text box of the photo browsing application developed in the previous section. Unless you query the user, you won't know whether the user meant "Ford Mustang" or "Ford F-150." One way to find out would be to create a page with HTML markup and display it to the user, asking for more information. You could then save the generated file to Isolated Storage, and load it using the technique described in the previous section (Using a WebBrowser Control to Display Local HTML Content). But that would certainly be a cumbersome approach for such a simple task. Luckily, there's a much easier way to show a dynamically generated HTML page: using the NavigateToString() method of the WebBrowser control. This method takes a single argument—a string—that contains all of the HTML needed to display the page you have in mind in the WebBrowser control.

The next walkthrough shows just how easy it is to use this method.

  1. Bring up the MainPage.xaml.cs file in the code editor (either by double-clicking it or clicking the MainPage.xaml file in the Solution Explorer and choosing View Code).

  2. Next, you will construct the HTML code to display to the user. Make the button1_Click method look identical to the following code—notice how NavigateToStringloads up what amounts to a basic HTML page directly into the WebBrowser control, without your having to save this HTML to the Isolated Storage. Also note that building an HTML string in code becomes a bit ugly very quickly, so NavigateToStringshould not be abused for large HTML messages/files.

    webBrowser1.NavigateToString(@"<html>
    <body><center><div style='font: Arial 12px;'>
    Which Ford
    model would you like to see?<br><br>
    <a href='http://www.bing.com/images/search?q=cars+Ford+Mustang'>Ford
    Mustang</a> or <a href='http://www.bing.com/images/search?q=cars+Ford+F150'>Ford F-
    150</a></div></center></body></html>");


  3. Press F5 to run the application. Now if you type "Ford" in the text box and press the "Show It!" button, you should see a dynamically generated HTML message with hyperlinks asking you to clarify which Ford model you would like to see, just like Figure 1.


Figure 1. Showing dynamically generated HMTL content

Many web-based applications have been built, from translators to elaborate e-commerce systems, and all of them are easily accessible and could even be potentially enhanced with the use of the WebBrowser control on Windows Phone 7. But the WebBrowser control can do even more: in the next section, we will learn how to save the web pages locally, so that we can potentially parse certain information or search within them.

Other  
 
Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us
programming4us
 
 
programming4us