那就用你那个办法,你可以用HttpWebRequest类来获取你需要页面的所有信息,然后你自己处理一下 下面代码是从msdn上面找到的关于HttpWebRequest的用法 Imports System Imports System.net Imports System.Text Imports System.IoPublic Class WebRequest1 ' Specify the URL to receive the request. Public Shared Sub Main(ByVal args() As String) Dim request As HttpWebRequest = CType(WebRequest.Create(args(0)), HttpWebRequest) ' Set some reasonable limits on resources used by this request request.MaximumAutomaticRedirections = 4 request.MaximumResponseHeadersLength = 4 ' Set credentials to use for this request. request.Credentials = CredentialCache.DefaultCredentials Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse) Console.WriteLine("Content length is {0}", response.ContentLength) Console.WriteLine("Content type is {0}", response.ContentType) ' Get the stream associated with the response. Dim receiveStream As Stream = response.GetResponseStream() ' Pipes the stream to a higher level stream reader with the required encoding format. Dim readStream As New StreamReader(receiveStream, Encoding.UTF8) Console.WriteLine("Response stream received.") Console.WriteLine(readStream.ReadToEnd()) response.Close() readStream.Close() End Sub 'Main End Class 'Test
在获得该URL地址的页面的Page_Load动作中添加以下代码。能够将HTML流显示在Table上。注意,Table不能直接对InnerHtml进行赋值而必须对其Rows[]Cells[]的InnerHtml进行操作,否则会出错。 private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 string strURL = this.Page.Request.QueryString["FN"] ; // create a new uri object with the node's target Uri myUri = new Uri(strURL) ; // create a new request to the above mentioned URL. WebRequest myWebRequest = WebRequest.Create(myUri) ; // Set the ContentType property myWebRequest.ContentType = "application/x-www-from-urlencoded" ;
// Assign the response object of 'WebRequest' to a 'WebResponse' variable. WebResponse myWebResponse = myWebRequest.GetResponse() ; // get response stream to a stream object Stream streamResponse = myWebResponse.GetResponseStream() ; StreamReader streamRead = new StreamReader(streamResponse) ; string strResponse = streamRead.ReadToEnd() ; // show the stream to the table this.Table1.Rows[0].Cells[0].InnerHtml = strResponse ; // Close the response to free resources. myWebResponse.Close() ; }
显示出来的页面不能显示中文!可能给这个Stream添加一个属性吧。怎么加呢?再研究研究。
哦,SORRY,该动一点: StreamReader streamRead = new StreamReader(streamResponse,Encoding.GetEncoding("GB18030")); 就OK了!
不知道具体怎么实现,请高手指点!
下面代码是从msdn上面找到的关于HttpWebRequest的用法
Imports System
Imports System.net
Imports System.Text
Imports System.IoPublic Class WebRequest1 ' Specify the URL to receive the request.
Public Shared Sub Main(ByVal args() As String)
Dim request As HttpWebRequest = CType(WebRequest.Create(args(0)), HttpWebRequest)
' Set some reasonable limits on resources used by this request
request.MaximumAutomaticRedirections = 4
request.MaximumResponseHeadersLength = 4 ' Set credentials to use for this request.
request.Credentials = CredentialCache.DefaultCredentials Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse) Console.WriteLine("Content length is {0}", response.ContentLength)
Console.WriteLine("Content type is {0}", response.ContentType) ' Get the stream associated with the response.
Dim receiveStream As Stream = response.GetResponseStream() ' Pipes the stream to a higher level stream reader with the required encoding format.
Dim readStream As New StreamReader(receiveStream, Encoding.UTF8) Console.WriteLine("Response stream received.")
Console.WriteLine(readStream.ReadToEnd())
response.Close()
readStream.Close()
End Sub 'Main
End Class 'Test
request.querystring("FN")
C#
Request.QueryString["FN"];
你可以加一个panel 然后把panel 拖到DIV上 继续 设置height 和 width 要知道 scrollbar 的宽度默认值是16看看可以么?
使用HTML编码就可以了,好象是enhtmlcode()
是
HtmlEnCode()吧
条件:已知html文件的URL地址,将该文件在自己窗体中的一个控件中显示出来,且能够被页面body中的javascript脚本控制。
想法:在页面的body中添加javascript脚本,将已知html文件通过URL地址获得流内容,再将该流内容再页面指定部分用页面形式显示。
<!-----莫用IFrame,难以用页面中的javascript脚本控制------!>
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string strURL = this.Page.Request.QueryString["FN"] ; // create a new uri object with the node's target
Uri myUri = new Uri(strURL) ; // create a new request to the above mentioned URL.
WebRequest myWebRequest = WebRequest.Create(myUri) ; // Set the ContentType property
myWebRequest.ContentType = "application/x-www-from-urlencoded" ;
// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse myWebResponse = myWebRequest.GetResponse() ; // get response stream to a stream object
Stream streamResponse = myWebResponse.GetResponseStream() ; StreamReader streamRead = new StreamReader(streamResponse) ; string strResponse = streamRead.ReadToEnd() ; // show the stream to the table
this.Table1.Rows[0].Cells[0].InnerHtml = strResponse ; // Close the response to free resources.
myWebResponse.Close() ; }
StreamReader streamRead = new StreamReader(streamResponse,Encoding.GetEncoding("GB18030"));
就OK了!