Introduction:
In this article, i am going to demonstrate how to integrate a web browser into asp.net application using c#.
Main:
We can use the Internet Explorer component included with .NET. In
Visual Studio, it shows up under Common Controls in the Form Designer.
It is quite simple to create your own web browser by using the existing functionality from
Internet Explorer.
Sample Code,
using System;
using System.ComponentModel;
using System.Windows.Forms;
namespace WebBrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonGo_Click(object sender, EventArgs e)
{
if (radioButtonUrl.Checked)
{
this.webBrowser1.Navigate(textBoxUrl.Text);
}
else
{
this.webBrowser1.DocumentText = textBoxHTML.Text;
}
}
private void OnRadioCheckedChanged(object sender, EventArgs e)
{
textBoxUrl.Enabled = radioButtonUrl.Checked;
textBoxHTML.Enabled = radioButtonHTML.Checked;
}
}
}
using System; using System.ComponentModel; using System.Windows.Forms; namespace WebBrowser { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void buttonGo_Click(object sender, EventArgs e) { if (radioButtonUrl.Checked) { this.webBrowser1.Navigate(textBoxUrl.Text); } else { this.webBrowser1.DocumentText = textBoxHTML.Text; } } private void OnRadioCheckedChanged(object sender, EventArgs e) { textBoxUrl.Enabled = radioButtonUrl.Checked; textBoxHTML.Enabled = radioButtonHTML.Checked; } } } |
Conclusion:
Hope this helps,
Happy Coding.
1 Comments.