i'm trying the load a page to may asp.net web form and extract only the text from it and display the extracted text in an Areatext
like this:
and my code is:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
#form1 {
height: 500px;
width: 1199px;
}
.auto-style1 {}
#TextArea1 {
height: 288px;
width: 1157px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Clike me"
OnClick="Button1_Click" OnClientClick="aspnetForm.target ='_blank';"
Width="160px" CssClass="auto-style1" Height="32px" />
<br />
<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>CNN</asp:ListItem>
<asp:ListItem>BBC</asp:ListItem>
<asp:ListItem>FOX</asp:ListItem>
</asp:RadioButtonList>
<br />
<br />
<textarea id="TextArea1" name="S1" runat="server" ></textarea></form>
</body>
</html>
and
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
public partial class _Default : System.Web.UI.Page
{
Uri url = null;
WebBrowser wb = new WebBrowser();
protected void Button1_Click(object sender, EventArgs e)
{
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DisplayText);
if (RadioButtonList1.Text == "CNN")
{
url = new Uri("http://www.edition.cnn.com/");
wb.Url = url;
//Response.Redirect(url);
}
else if (RadioButtonList1.Text == "BBC")
{
url = new Uri("http://www.bbc.com/");
wb.Url = url;
}
else
{
url = new Uri("http://www.foxnews.com/");
wb.Url = url;
}
}
private void DisplayText(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser wb = (WebBrowser)sender;
wb.Document.ExecCommand("SelectAll", false, null);
wb.Document.ExecCommand("Copy", false, null);
TextArea1.Value = Clipboard.GetText();
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
but i have this error in line
WebBrowser wb = new WebBrowser();
ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
so what i'm doing wrong pleas help and many thanks in advance