0

我有一个位于网页上的用户控件,并且该网页显示在 iFrame 中。

表格来源:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="FileUploadForm.aspx.vb"
Inherits="IST.FileUploadForm" %>

<%@ Register Src="myFileUpload.ascx" TagName="myFileUpload" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <title></title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:PlaceHolder ID="ph1" runat="server"></asp:PlaceHolder>
      </div>
    </form>
  </body>
</html>

后面的代码:

Imports System.IO

Public Class FileUploadForm
  Inherits System.Web.UI.Page

  Private WithEvents myFileUpload1 As myFileUpload

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim myUploadLocation As String

    myUploadLocation = Request.QueryString("loc")
    If myUploadLocation = Nothing Then
      myUploadLocation = Server.MapPath("~\temp")
    End If

    Dim allowed As String

    allowed = Request.QueryString("accepts")
    If allowed = Nothing Then
      allowed = ""
    End If

    myFileUpload1 = CType(Me.LoadControl("myFileUpload.ascx"), myFileUpload)
    myFileUpload1.ID = "fuOfferte"
    myFileUpload1.AllowedFiles = allowed
    myFileUpload1.FileLabelText = "File"
    myFileUpload1.NotAllowedText = "This file extention is not allowed."
    myFileUpload1.UploadButtonText = "Upload file"
    myFileUpload1.UploadLocation = myUploadLocation

    ph1.Controls.Add(myFileUpload1)

  End Sub

  Private Sub myFileUpload1_FileUploaded(file As String) Handles myFileUpload1.FileUploaded
    Session("UploadedFileName") = file
  End Sub
End Class

主页后面的代码:

pnMNCfile = New Panel
pnMNCfile.ID = "pnMNCfile"
pnMNCfile.Style("position") = "absolute"
pnMNCfile.Style("left") = "45px"
pnMNCfile.Style("top") = "30px"
pnMNCfile.Style("width") = "540px"
If Request.Browser.Browser.ToLower = "ie" = False Or (Request.Browser.Browser.ToLower = "ie" = True And CInt(Request.Browser.Version.Substring(0, 1)) > 8) Then
  pnMNCfile.Style("height") = "80px"
Else
  pnMNCfile.Style("height") = "87px"
End If
pnMNCfile.Style("z-index") = "999"
pnMNCfile.BorderStyle = BorderStyle.None
pnMNCfile.BackColor = Drawing.Color.LightGray
pnMNCfile.BorderWidth = 1
pnMNCfile.Attributes.Add("OnMouseOut", "BalloonPopupControlBehavior.hidePopup();")
pnMNC3.Controls.Add(pnMNCfile)

Dim lit As New Literal
lit.Text = "<IFRAME id=""frMNCfileUpload"" frameborder=""0"" scrolling=""auto"" allowtransparency=""true"" runat=""server"" width=""100%"" height=""100%"" src=""FileUploadForm.aspx?loc=" + CStr(Session("userfolder")) + "&accepts=xls_xlsx_doc_docx""></IFRAME>"
pnMNCfile.Controls.Clear()
pnMNCfile.Controls.Add(lit)

问题是当页面在 IE9 中加载时,您很快就会看到 iframe(不到 0.5 秒)。在 Chrome 中,它是可见的,没有任何问题。当我在 iframe 区域中单击鼠标右键并进行刷新时,内容可见。

我还尝试在 iframe 周围设置边框。当它不可见时,边框也不可见。在 chrome 中,您也可以看到边框。

这里发生了什么?这是 IE 中的错误还是(更有可能)我做错了什么?肮脏的解决方法是使用用户控件向网页添加自动刷新。

有什么想法吗?

rg,埃里克

4

1 回答 1

1
I had the same issue with IE9 for various reasons and works with Chrome.

1. Configure Asp.net to use a cookieless session state. This might help...

    <sessionState cookieless="true" mode="InProc"></sessionState>
  </system.web>

</configuration>

or

2.

or try this too:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

example:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GeneralLedgerCodeListingCustomForm.aspx.cs" Inherits="xyz.GeneralLedgerCodeListingCustomForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
%>
于 2013-06-19T16:57:07.160 回答