小弟想将一些网页文件,通过连接按钮,在指定页面的DIV或者TABLE中显示出来。连接按钮的URL属性中传递过去的值为"item.aspx?FN=xxx.htm",现在想在item.aspx页面获取FN=后面的值,并将该页面在item.aspx中的DIV中显示出来,请问如何设计?
请大家帮忙,谢谢!

解决方案 »

  1.   

    这个方法不知道能否行的通:先获得"FN="后面的值,然后读取该htm/html文件的流内容,将该流内容在Table或者DIV中再显示成网页。
    不知道具体怎么实现,请高手指点!
      

  2.   

    不知道用iframe可以吗,在里面加入你从FN=后面的值作为iframe的src
      

  3.   

    呵呵,我现在就是因为iframe不能随便控制页面的右键,才出此下策,用另外的一个页面来显示,并将该页面保存到iframe中去。iframe有一个好处,可以控制页面的宽度,但是其中的页面属于独立的一个页面,比较难以控制。
      

  4.   

    那就用你那个办法,你可以用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
      

  5.   

    请问兄弟,我在item.aspx页面上怎么获取FN=后面的值?
      

  6.   

    vb.net
    request.querystring("FN")
    C#
    Request.QueryString["FN"];
      

  7.   

    URL可以取出来,item.aspx页面也可以在iframe中显示出来,但是,怎么将URL所对应的htm文件在item.aspx页面中的DIV中显示呢?搞了半天也没有搞出来。急盼高手指点!
      

  8.   

    我也说下
    你可以加一个panel 然后把panel 拖到DIV上 继续 设置height 和 width  要知道 scrollbar 的宽度默认值是16看看可以么?
      

  9.   

    使用HTML编码就可以了,好象是enhtmlcode()
      

  10.   

    回复人: leihome(yukim) ( ) 信誉:96 
    使用HTML编码就可以了,好象是enhtmlcode()

    HtmlEnCode()吧
      

  11.   

    HtmlEnCode()的作用是将一个字符串进行HTML编码并返回编码后的字符串,在这里有什么用么?
      

  12.   

    谁能给我一个完整的代码,单独另赠100!!!!
    条件:已知html文件的URL地址,将该文件在自己窗体中的一个控件中显示出来,且能够被页面body中的javascript脚本控制。
    想法:在页面的body中添加javascript脚本,将已知html文件通过URL地址获得流内容,再将该流内容再页面指定部分用页面形式显示。
    <!-----莫用IFrame,难以用页面中的javascript脚本控制------!>
      

  13.   

    <!-----谁能给我一个完整的代码,单独另赠100!!!!------!>
      

  14.   

    在获得该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() ; }
      

  15.   

    显示出来的页面不能显示中文!可能给这个Stream添加一个属性吧。怎么加呢?再研究研究。
      

  16.   

    哦,SORRY,该动一点:
    StreamReader streamRead = new StreamReader(streamResponse,Encoding.GetEncoding("GB18030"));
    就OK了!