Showing posts with label Web Browser. Show all posts
Showing posts with label Web Browser. Show all posts

Sep 22, 2011

Displaying the HTML format content into Rich text box using c#

In general way .net programmers use the built-in web browser control to display the HTML format content in the windows applications.it is very simple to do.But the web browser control visual appearance (font wise) is not same as the windows controls (Label,Rich Text Box) appearance.we never get windows font look using web browser control because always there is difference between web and windows visualization.
To over come this apply the simple trick here.
  1.  Place the rich text box control in the form.
  2. Create the Web Browser control form the code behind
  3.  Bind the html content to web browser.
  4. Select and copy the html content Using the HTML document ExecCommand()
  5. Paste content to rich text box using the paste() method of Rich text box
Here is the code looks like.

var webBrowser = new WebBrowser();
webBrowser.CreateControl(); // only if needed
webBrowser.DocumentText = "<html><body><b>DotnetCyphers</b></body></html>";
while (webBrowser.DocumentText != "<html><body><b>DotnetCyphers</b></body></html>")

Application.DoEvents();
webBrowser.Document.ExecCommand("SelectAll", false, null);
webBrowser.Document.ExecCommand("Copy", false, null);
richTextBox1.Paste();
richTextBox1.ReadOnly = true;

ExecCommand() executes a command on the current document,/current selection/ the given range.

Aug 10, 2011

Web Browser’s Role

client is an application that runs on a personal computer and relies on a server to perform operations.In our case web browser is the client to access web pages resides on the web server.
web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web.
Their role is relatively simple:

1. Send requests to the web server.
If the user enters http://www.dotnetcypher.com, the web browser resolves the www.dotnetcypher.com Domain Name System (DNS) address, uses HTTP to connect to the server, and requests a page.
2. Authenticate the server.
If the server has an SSL certificate and the request was made with HTTPS, the web browser uses the certificate to authenticate the server and then decrypt future communications.
3. Process the response.
If the server has provided HTML, the browser retrieves embedded objects, such as images, videos, or animations referenced in the HTML. If the server has provided an error, redirection, or other response, the browser responds appropriately.
4. Display HTML and embedded objects.
Web browsers use HTML standards to determine how to display a webpage to the user. Because HTML can contain embedded objects, a web browser might have to display dozens of objects to render a single webpage.
5. Run client scripts.
Client scripts, such as those written in JavaScript, enable interactive and responsive pages without reloading the page.

Here are the more links.

http://www.allaboutcookies.org/browsers/index.html
http://create-website.org/concepts/webbrowser.html